instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Imagine you're creating a presentation that will be translated into a dozen different languages, including ones with non-latin characters (Chinese, for instance). The client's branding style guide dictates that certain fonts are acceptable for certain languages. The content itself is required to be externalized, so ...
<p>This is a bit of a hassle in flash, but it is entirely possible. What you will need to do is to "embed" the font inside a separate swf, load this swf from your main application and then register that font inside that swf aswell. This will allow you to do runtime loading of fonts. This will require you to either spe...
<p>Well, you'll some how have to know what language you're loading. Autodetection can be quite difficult.</p> <p>Assuming you know what language the content is you can register fonts to be used in runtime using <a href="http://livedocs.adobe.com/flex/3/langref/flash/text/Font.html#registerFont()" rel="nofollow norefer...
27,801
<p>I feel like I'm missing a fairly fundamental concept to WPF when it comes to databinding, but I can't seem to find the right combination of Google keywords to locate what I'm after, so maybe the SO Community can help. :)</p> <p>I've got a WPF usercontrol that needs to databind to two separate objects in order to di...
<p>I would probably use a CustomControl with two DependencyProperties. Then the external site that uses your custom control could bind the data that they want to that control, also by using a custom control you can template the way the control looks in different situations.</p> <p>Custom control code would look someth...
<p>The reason your text boxes don't update is that you are binding them to a StaticResource. As the name implies these resources are static and don't post change notifications. And because Binding is a MarkupExtension and does not derive from DependencyObject you can't use a DynamicResource.</p> <p>Try creating depede...
32,887
<p>I'm new to postgreSQL and I have a simple question:</p> <p>I'm trying to create a simple script that creates a DB so I can later call it like this:</p> <pre><code>psql -f createDB.sql </code></pre> <p>I want the script to call other scripts (separate ones for creating tables, adding constraints, functions etc), l...
<p>Postgres started on Linux/Unix. I suspect that reversing the slash with fix it.</p> <pre><code>\i somedir/script2.sql </code></pre> <p>If you need to fully qualify something</p> <pre><code>\i c:/somedir/script2.sql </code></pre> <p>If that doesn't fix it, my next guess would be you need to escape the backslash...
<p>i did try this and its working in windows machine to run a sql file on a specific schema.</p> <blockquote> <p>psql -h localhost -p 5432 -U username -d databasename -v schema=schemaname &lt; e:\Table.sql </p> </blockquote>
15,740
<p>I've got a WinForms .Net app that runs over a lot of XPS documents (thousands) and during this run the number of handles (according sysinternals process monitor and task manager) increases by between 3-10 for each document. I heavily suspect that these are handles that are opened and not closed by the MS .Net XPS fr...
<p>Possibly stupid, but have you checked that you're disposing everything that's disposable?</p>
<p>So, did you forget to remove the XPS Documents you've created form the PackageStore? And what about any MemoryStreams used to back your Packages?</p>
28,656
<p>System.IO.BinaryReader reads values in a little-endian format.</p> <p>I have a C# application connecting to a proprietary networking library on the server side. The server-side sends everything down in network byte order, as one would expect, but I find that dealing with this on the client side is awkward, particu...
<p>There is no built-in converter. Here's my wrapper (as you can see, I only implemented the functionality I needed but the structure is pretty easy to change to your liking):</p> <pre><code>/// &lt;summary&gt; /// Utilities for reading big-endian files /// &lt;/summary&gt; public class BigEndianReader { public B...
<p>I built a custom BinaryReader to handle all of this. It's available as <a href="http://www.assembla.com/wiki/show/nextem" rel="nofollow noreferrer">part of my Nextem library</a>. It also has a very easy way of defining binary structs, which I think will help you here -- check out the Examples.</p> <p>Note: It's ...
15,071
<p>What are the best approaches / tools to test browser extensions?</p> <p>In my case I work on an IE Browser Helper Object (C#) which has a small UI of its own and a good deal of database interaction. Up till now we've used automated unit tests for testing our model/business objects but manual testing for the UI/scen...
<p>We used to use Selenium, but then we switched over to <a href="http://webiussoft.com/" rel="nofollow noreferrer">Webius</a> SWExplorerAutomation (SWEA).</p> <p>A benefit of using Webius is that we can generate c#, wrap them in nunit tests, and compile the tests into .NET assemblies to integrate into our build scrip...
<p>We decided to use <a href="http://watin.org/" rel="nofollow">WatiN</a> as it was more lightweight than Selenium. We use this for IE and Firefox.</p>
17,407
<p>I have a .net web-service hosted in IIS 6.0 that periodically fails with an http 500 because a client connects to it with data that does not match the wsdl.</p> <p>Things like having an element specified in a method as being of type int and the inbound xml element contains a decimal number.</p> <p>WSDL element def...
<p>You could implement a global exception handler in your web service that logs the details of any exceptions that occur. This is useful for your current problem, plus it's very useful in a production environment as it gives you an insight into how many exceptions are being thrown and by what code.</p> <p>To implemen...
<p>After some thinking of my own, the current best solution I can see is to throw together a light weight facade web-service that accepts an xml blob as input. </p> <p>I can then get my facade service to call the real service with the input data provided by the client and then:</p> <ul> <li>handle any errors, logging...
25,815
<p>I'm just getting started with C# and often find myself going back to other projects and reusing some snippet of code in a new project. </p> <p>Is there a good tool out there with which on can store all the little pieces of code they reuse again and again AND integrates with Visual Studio Express?? </p>
<p>Visual studio has the concept of code snippets, under the tools menu there is a code snippets manager.</p> <p>Almost forgot, to bring up the code snipped menu in code press CRTL+K+S.</p>
<p><a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio_Express#Extensibility" rel="nofollow noreferrer">Visual Studio Express is not legally extensible</a> so I doubt there is a tool you can purchase or download that will integrate. However, <a href="http://www.codeplex.com/snippy" rel="nofollow noreferrer">s...
35,295
<p>I just downloaded Eclipse several hours ago, and needed to add Java3D to the classpath. Installing it went without a hitch, but Eclipse can't seem to find the documentation folders so that it can give super-IDE functionality, such as autocomplete and method signatures.</p> <p>While I know how I would add them indiv...
<p>when you add a .JAR(library) to your project in the LIBRARIES tab for your project, you have the option of attaching the javadoc directory for the jar.</p> <p>So, go to the LIBRARIES tab of the "java build path" for your projects. select your jar. expand the (+) sign and you will see that you can set the javadoc. p...
<p>As far as I know (haven't used 3.4 very much thus far), Eclipse has two options for the automatic showing of Javadocs. The first is a JavaDoc jar to attach to the jar file. The second is having the javadoc in a source jar which is attached to the jar to show the source.</p> <p>A directory, if I recall correctly, ...
25,404
<p>In a project I'm working on FxCop shows me lots of (and I mean more than 400) errors on the InitializeComponent() methods generated by the Windows Forms designer. Most of those errors are just the assignment of the Text property of labels.</p> <p>I'd like to suppress those methods in source, so I copied the suppres...
<p>You've probably got the right code, but you also need to add CODE_ANALYSIS as a precompiler defined symbol in the project properties. I think those SuppressMessage attributes are only left in the compiled binaries if CODE_ANALYSIS is defined.</p>
<p>Module level suppression messages need to be pasted into the same file as the code that is raising the FxCop error before the namespace declaration or in assemblyinfo.cs. Additionally, you will need to have CODE_ANALYSIS defined as a conditional compiler symbols (Project > Properties > Build). Once that is in place,...
5,609
<p>Imagine the following. </p> <ol> <li>Html is parsed into a dom tree</li> <li>Dom Nodes become available programmatically </li> <li>Dom Nodes may-or-may-not be augmented programmatically</li> <li>Augmented nodes are reserialised to html. </li> </ol> <p>I have primarily a question on how one would want the <b>"scrip...
<p>I'm adding my own answer here, so its more obvious what I'm trying to find out. The current idea I have settled on would perform as follows:</p> <pre><code>my $html=&lt;&lt;'EOF' &lt;script&gt; //&lt;!--&lt;![CDATA[ foo //]]&gt;--&gt; &lt;/script&gt; EOF #/# this line is here for the syntax highlighter my $obj = pa...
<p>The only thing similar I can think of is in ASP.NET's register script block functions. They all have an overload that takes a bool for whether script tags should be added or not.</p> <p>Here's a link to the docs for one:</p> <p><a href="http://msdn.microsoft.com/en-us/library/bahh2fef.aspx" rel="nofollow noreferr...
36,033
<p>I have a Button inside an UpdatePanel. The button is being used as the OK button for a ModalPopupExtender. For some reason, the button click event is not firing. Any ideas? Am I missing something?</p> <pre><code>&lt;asp:updatepanel id="UpdatePanel1" runat="server"&gt; &lt;ContentTemplate&gt; &lt;cc1...
<p>Aspx</p> <pre><code>&lt;ajax:ModalPopupExtender runat="server" ID="modalPop" PopupControlID="pnlpopup" TargetControlID="btnGo" BackgroundCssClass="modalBackground" DropShadow="true" CancelControlID="btnCancel" X="470" Y="300" /&gt; //Codebehind ...
<p>I've found a way to validate a modalpopup without a postback.</p> <p>In the ModalPopupExtender I set the OnOkScript to a function e.g ValidateBeforePostBack(), then in the function I call Page_ClientValidate for the validation group I want, do a check and if it fails, keep the modalpopup showing. If it passes, I ca...
17,234
<p>I'm working on a project which makes substantial use of code generation. Some of the files it generates contain >0.25 million lines of code. VS (2K5) doesn't cope too badly, but R# (4.01) throws an out of memory exception every two minutes or so.</p> <p><strong>Splitting them out into partial classes/separate files...
<p>I would at least change huge files extention to something like <em>.cpp_gen</em> or <em>.cpp_huge</em> to remove syntax highlighting, outlining etc. and then reassign build tool back to <em>C/C++ compiler tool</em> for them.</p>
<p>Can't you break up the files and use the preprocessor to bring them back together when you compile?</p>
25,491
<p>Are there any popular Mysql rss feeds you guys can recommend? IBM has random articles but those are usually not enough</p>
<p>Planet Mysql is an obvious answer. It's a blog aggregator. Of course there are other sites that are not included in this aggregation, but this one has more than any other single site.</p> <p><a href="http://www.planetmysql.org/rss20.xml" rel="nofollow noreferrer">http://www.planetmysql.org/rss20.xml</a></p>
<p><a href="http://www.mysqlperformanceblog.com/feed/" rel="nofollow noreferrer">http://www.mysqlperformanceblog.com/feed/</a></p> <p><a href="http://www.mysqlperformanceblog.com" rel="nofollow noreferrer">http://www.mysqlperformanceblog.com</a></p>
25,332
<p>Do you know any resources that teach to good habits of working in UNIX command line?</p> <p>EDIT: I don't mean general books about shell or man pages. I mean the things that you can only see watching professionals working with command line. For example when changing frequently between two directories they use "pus...
<p>I am speaking out of my own experience so it may not apply to you;</p> <p>The best way to be efficient is actually using it on a daily basis, instead of using graphical tools even if they make look things easy. You will then become aware of most common tasks you care about, and instead of trying to grok it at once,...
<p>Join a LUG. That is where I learned most things early on. Ask the organizers to do a "Bash Tips And Tricks Night". </p> <p>Deft shell users love to show off.</p>
40,161
<p>Is anyone out there using D for real world applications? If so, what are you using it for? I can't seem to find anything big on the web written in D.</p> <p>Despite the lack of known big users, D seems like a very promissing language to me, and according to <a href="http://www.tiobe.com/index.php/content/paperinfo/...
<p>I'm using D for my research work in the area of computer graphics. I and others have had papers published in our fields based on work done using D. I think it's definitely ready for use on small to medium sized research projects where performance matters. It's a nice fit for research work because often you're sta...
<p>I started a ray-traced renderer in D with ldmd2.</p> <p><a href="http://palaes.rudanium.org/SubSpace/render.php" rel="nofollow">http://palaes.rudanium.org/SubSpace/render.php</a></p>
8,020
<p>Using the viewer control for display of SQL Reporting Services reports on web page (Microsoft.ReportViewer.WebForms), can you move the View Report button? It defaults to the very right side of the report, which means you have to scroll all the way across before the button is visible. Not a problem for reports that f...
<p>It's kind of a hack, but you can move it in JavaScript. Just see what HTML the ReportViewer generates, and write the appropriate JavaScript code to move the button. I used JavaScript to hide the button (because we wanted our own View Report button). Any JavaScript code that manipulates the generated ReportViewer's H...
<p>I had the same problem and ended up using an extension on Travis Collins answer; As well as changing the table column width I also align the "View Report" button left so that it appears neearer to rest of the controls.</p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function() { $(...
4,108
<p>I am juststarting out with flash, and I know that motion tweening can automate simple things, but I would like to know if there are more ways to automate?</p> <p>For example, the animation of the bird here:</p> <p><a href="http://www.youtube.com/watch?v=As_-K8xGqLE" rel="nofollow noreferrer">http://www.youtube.com...
<p>Also, try setting your debugger to Mixed. This will allow debugging of both managed and unmanaged code.</p>
<p>You sure you enabled all the debugging options? I have seen this happen when 'forgetting' some when trying to navigate the maze of C++ options.</p>
43,310
<p>I am actually loading a page as a modal dialog box as window.showModalDialog("url.aspx"). The first time the modal dialog is poped up the page load event gets called. When i close it and call the same again, the Control does not come to the PageLoad. Instead the page pops up with the previous values in all its contr...
<p>ok....you do know showModalDialog is an proprietary IE only feature? As long as you are aware of this then I think you may need to add a unique querystring value to the url that you are using to avoid ie showing the cached version. So generate a random number and append it to the url e.g url.aspx?rnd=12237827348273....
<p>Firefox 3 supports <a href="https://developer.mozilla.org/en/DOM/window.showModalDialog" rel="nofollow noreferrer">https://developer.mozilla.org/en/DOM/window.showModalDialog</a></p>
22,587
<p>Which family should I start to learn? (Never did any programming on microcontroller)</p>
<p>Today AVR and PIC are probably the most common microcontrollers among hobbyists. Both have a very wide range of device variants and both can be used to achieve similar results.</p> <p>For a beginner I would suggest AVR due to various reasons:</p> <ul> <li><p>AVR family (tiny, mega) is coherent and easy to understa...
<p>I started on a Motorola M68HC11, it was simple enough. I think you'll get about the same experience with any 8Bit controllers.</p>
16,946
<p>Is there a way to generate random number on Windows by reading from a file or pseudo file or character special file, the way that can be done on Linux by reading from <a href="http://en.wikipedia.org/wiki/Urandom#Linux" rel="nofollow noreferrer">/dev/random</a>? Not asking about various crypto API, but whether there...
<p>Yes, it's called <a href="http://en.wikipedia.org/wiki/Entropy_(computing)#Windows" rel="nofollow noreferrer">Microsoft CryptoAPI</a>.</p>
<p>If you're doing .NET development you can use the <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.randomnumbergenerator.aspx" rel="nofollow noreferrer">RandomNumberGenerator</a> class.</p>
23,232
<p>I created 26 <kbd>JButton</kbd> in an anonymous <code>actionListener</code> labeled as each letter of the alphabet.</p> <pre><code>for (int i = 65; i &lt; 91; i++){ final char c = (char)i; final JButton button = new JButton("" + c); alphabetPanel.add(button); button.addActionListener( new Ac...
<p>Could you not simply declare an array of 26 JButton objects at class level, so that both listeners can access them? I believe anonymous inner classes can access class variables as well as final variables.</p>
<p>You could also iterate through the components, comparing getText() to the key pressed.</p> <p>As someone else mentioned, anonymous classes can also access members of the outer class as well as local finals</p>
36,444
<p>When you rotate an image using canvas, it'll get cut off - how do I avoid this? I already made the canvas element bigger then the image, but it's still cutting off the edges.</p> <p>Example:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;test&lt;/title&gt; &lt;script type="text/javascrip...
<p>Rotation always occur around the current origin. So you might want to use translate first to translate the canvas to the position around which you want to rotate (say the center) then rotate.</p> <p>e.g.</p> <pre><code>ctx.translate(85, 85); ctx.rotate(5 * Math.PI / 180); </code></pre> <p>The canvas now rotates a...
<p>I created a complete function that arranges the image according to the angle and position</p> <pre><code>function drawImage(myContext,imgSrc, x, y, size, rotate) {&lt;br/&gt; var halfS = size / 2;&lt;br/&gt; var imageCursor = new Image();&lt;br/&gt; imageCursor.src = imgSrc;&lt;b...
47,689
<p>Can I use javascript in a page to cause an event in a silverlight component to fire? If so, does anybody have some code samples?</p>
<p>Yes, you can. You need to decorate a method on a class in your .NET code with the "ScriptableMember" attribue and then call HtmlPage.RegisterScriptableObject on your object to mark it for interoperability with javascript. You'd create your .NET method called something like OnMyEvent(sender As Object, e As MyEventArg...
<p>Video walk through here: <a href="http://silverlight.net/learn/learnvideo.aspx?video=65683" rel="nofollow noreferrer">http://silverlight.net/learn/learnvideo.aspx?video=65683</a> </p>
44,835
<p>I'm currently in the planning stage for a web application and I find myself trying to decide on using Grails or Django. From an operation perspective:</p> <ol> <li><p>Which ecosystem is easier to maintain (migrations, backup, disaster recovery etc.)? If using grails it'll probably be a typical tomcat + mysql on l...
<p>You can run grails in 256 megs of ram. Many members of the community are doing so. That being said I would say in either platform you want much more ram than that to make sure your performant. But I might also reccomend checking out www.linode.com. You can get quality hosting for a very reasonable cost and addin...
<p>i think python tend to have lower hosting requirements (i.e., grails needs a jvm, and most el-cheapo hosts dont provide one, where as they usually provide python support). Plus google app engine supports django (to some extend). </p> <p>But if you got the dough, grails is so much better imho. </p>
23,700
<p>Even before telling my question, will tell you that this is a very vague question. But please let me know if you have any similar ideas. </p> <p>I am actually trying to write a website of my own locally using ASP.Net. I actually wanted to try and simulate a website with trading and stock details. I wanted to actual...
<p>Yes, you can use ASP.Net to fetch data from other websites, though generally speaking if you're planning on making a large site the scraping off other sites is done "offline", and the ASP.Net application serves off this cache of crawled pages. Keep in mind that heavy traffic coming from a single IP (ie, your server...
<p>Generally I'd grab data like that from a webservice provided by the data source. Although I doubt you could find such a service for free.</p>
40,506
<p>I was wondering how to make a toolbar in MFC that used 24bit or 256 colour bitmaps rather than the horrible 16 colour ones.</p> <p>Can anyone point me in the direction of some simple code?</p> <p>Thanks</p>
<p>The reason this happens is that the MFC CToolbar class uses an image list internally that is initialised to use 16 colours only. The solution is to create our own image list and tell the toolbar to use that instead. I know this will work for 256-colours, but I haven't tested it with higher bit-depths:</p> <p>First,...
<p>The solution worked Flawless, you only need to fix it a little:</p> <pre><code>CImageList m_imagelist; m_imagelist.Create(20, 20, ILC_COLOR8, 4, 4); m_imagelist.Add(&amp;bm, (CBitmap*) NULL); </code></pre>
32,713
<p>It's the first <a href="http://oreilly.com/catalog/opensources/book/larry.html" rel="nofollow noreferrer">great virtue</a> of programmers. All of us have, at one time or another automated a task with a bit of throw-away code. Sometimes it takes a couple seconds tapping out a one-liner, sometimes we spend an exorbita...
<p>i found this on dotfiles.org just today. it's very simple, but clever. i felt stupid for not having thought of it myself.</p> <pre><code>### ### Handy Extract Program ### extract () { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xvjf $1 ;; *.tar.gz) tar xvzf ...
<p>This goes back to my COBOL days but I had two generic COBOL programs, one batch and one online (mainframe folks will know what these are). They were shells of a program that could take any set of parameters and/or files and be run, batch or executed in an IMS test region. I had them set up so that depending on th...
21,298
<p>I found a question here about blogs on software development, but I would like to know which blogs on software testing this community reads.</p> <p>If you just have to recommend more than one blog, post each one in separate answer, so others can vote on specific blog. :)</p> <p>Thanks!</p> <p><strong>Edit:</strong...
<p>My <a href="http://blogs.msdn.com/alanpa" rel="nofollow noreferrer">blog</a>, of course, is quite interesting - but will not be to everyone. TestingReflections is nice because it aggregates a bunch of random test blogs, but the problem is that it aggregates the bad with the good. Many of the posts that make it to th...
<p>For Russian-speaking community is definitely:</p> <p><a href="http://it4business.ru/forum/index.php?showforum=192" rel="nofollow noreferrer">http://it4business.ru/forum/index.php?showforum=192</a></p> <p>But I think everybody knows that :)</p>
11,360
<p>What are in your opinion big differences between areas of usage for "Astoria" (ADO.NET data services) and SQL Server Data Services?</p>
<p>They are similiar but very different technologies. Astoria or what is now called at <a href="http://msdn.microsoft.com/en-us/data/bb931106.aspx" rel="nofollow noreferrer">Microsoft ADO.NET Data Services</a> is a programming library that will allow data to be passed through RESTful web services. You develop these we...
<p>I'm pretty sure you can call both Astoria and SQL Data Services with the same code in your app. So it depends on where you want your data - on your servers or in the cloud.</p>
9,510
<p>I'm creating a self updating app where I have the majority of the code in a seperate DLL. It's command line and will eventually be run on Mono. I'm just trying to get this code to work in C# on windows at the command line.</p> <p>How can I create a c# application that I can delete a supporting dll while its running...
<p>The only way I've ever managed something similar is to have the DLL in a separate AppDomain to the assembly that is trying to delete it. I unload the other AppDomain and then delete the DLL from disk.</p> <p>If you're looking for a way to perform the update, off the top of my head I would go for a stub exe that spa...
<p>Unwrap will load the assembly of the object's type into the appdomain that calls it. One way around this is to create a type in your "base" assembly that calls command.run, then load that into your new appdomain. This way you never have to call unwrap on an object from a type in a different assembly, and you can d...
21,642
<p>I have build a website. in that website there is section to download file using php script. our company has two ISP connections. one ISP allows to dowload file but other blocks it.</p> <p>i thought this is browser problem but after hit and try methods, i come to conclusion that this is ISP problem. Am i right. plea...
<p>Technically, it's not the webserver that overrides the .htaccess but the other way around, and some settings indeed may not be allowed to be overridden in htaccess from the server configuration.</p>
<p>Some files' extension might be prevented from downloading by the <strong>web server</strong> configuration.</p>
29,408
<p>What's the best practice for using a <code>switch</code> statement vs using an <code>if</code> statement for 30 <code>unsigned</code> enumerations where about 10 have an expected action (that presently is the same action). Performance and space need to be considered but are not critical. I've abstracted the snippet...
<p>Use switch.</p> <p>In the worst case the compiler will generate the same code as a if-else chain, so you don't lose anything. If in doubt put the most common cases first into the switch statement.</p> <p>In the best case the optimizer may find a better way to generate the code. Common things a compiler does is to ...
<p>I would pick the if statement for the sake of clarity and convention, although I'm sure that some would disagree. After all, you are wanting to do something <code>if</code> some condition is true! Having a switch with one action seems a little... unneccesary.</p>
12,349
<p>I need a way to do key-value lookups across (potentially) hundreds of GB of data. Ideally something based on a distributed hashtable, that works nicely with Java. It should be fault-tolerant, and open source.</p> <p>The store should be persistent, but would ideally cache data in memory to speed things up.</p> <p...
<p>You might want to check out <a href="http://www.hazelcast.com" rel="noreferrer">Hazelcast</a>. It is distributed/partitioned, super lite, easy and free.</p> <pre><code>java.util.Map map = Hazelcast.getMap ("mymap"); map.put ("key1", "value1"); </code></pre> <p>Regards,</p> <p>-talip</p>
<p>DNS has the capability to do this, I don't know how large each one of your records is (8GB of tons of small data?), but it may work.</p>
24,107
<p>I am writing an application which blocks on input from two <code>istreams</code>.</p> <p>Reading from either <code>istream</code> is a synchronous (blocking) call, so, I decided to create two <code>Boost::thread</code>s to do the reading.</p> <p>Either one of these threads can get to the "end" (based on some input...
<p>I don't think there is a way to do it cross platform, but pthread_cancel should be what you are looking for. With a boost thread you can get the <a href="http://www.boost.org/doc/libs/1_37_0/doc/html/thread/thread_management.html#thread.thread_management.thread.nativehandle" rel="nofollow noreferrer">native_handle</...
<p>Rather than trying to kill your thread, you can always tryjoin the thread instead, and if it fails, you join the other one instead. (Assuming you will always be able to join at least one of your two threads).</p> <p>In boost:thread you're looking for the <a href="http://www.boost.org/doc/libs/1_37_0/doc/html/threa...
34,340
<p>I'm a C# developer who's fumbling in the first VB code he's written since VB6, so if I am asking a rather obvious question, please forgive me.</p> <p>I decided to experiment with XML Literals to generate some XML code for me, instead of using XMLDocument</p> <p>I have 2 questions, the second regarding a workaround...
<p>VB.NET XML Literals are very powerful, but most often adding some LINQ to them makes them truly awesome. This code should do exactly what you're trying to do.</p> <pre><code>Dim Elements = New Dictionary(Of String, String) Elements.Add("Key1", "Value1") Elements.Add("Key2", "Value2") Elements.Add("Key3", "Value3") ...
<p>We would all be remiss not to mention that dynamic XML element names are generally a bad idea. The whole point of XML is to create a store a data structure in a form that is readily:</p> <ol> <li>Verifiable</li> <li>Extendable</li> </ol> <p>Dynamic element names fail that first condition. Why not simply use a stan...
7,379
<p>I mean, I always was wondered about how the hell somebody can develop algorithms to break/cheat the constraints of legal use in many shareware programs out there.</p> <p>Just for curiosity.</p>
<p>Apart from being illegal, it's a very complex task.</p> <p>Speaking just at a teoretical level the common way is to disassemble the program to crack and try to find where the key or the serialcode is checked. </p> <p>Easier said than done since any serious protection scheme will check values in multiple places and...
<p>I assume each crack is different, but I would guess in most cases somebody spends a lot of time in the debugger tracing the application in question.</p> <p>The serial generator takes that one step further by analyzing the algorithm that checks the serial number for validity and reverse engineers it.</p>
15,795
<p>I'm having some inheritance issues as I've got a group of inter-related abstract classes that need to all be overridden together to create a client implementation. Ideally I would like to do something like the following:</p> <pre><code>abstract class Animal { public Leg GetLeg() {...} } abstract class Leg { } ...
<p>The short answer is that GetLeg is invariant in its return type. The long answer can be found here: <a href="http://blogs.msdn.com/ericlippert/archive/2007/10/16/covariance-and-contravariance-in-c-part-one.aspx" rel="noreferrer">Covariance and contravariance</a></p> <p>I'd like to add that while inheritance is usua...
<p>Right, I understand that I can just cast, but that means the client has to know that Dogs have DogLegs. What I'm wondering is if there are technical reasons why this isn't possible, given that an implicit conversion exists.</p>
6,913
<p>I have a Pylons app where I would like to move some of the logic to a separate batch process. I've been running it under the main app for testing, but it is going to be doing a lot of work in the database, and I'd like it to be a separate process that will be running in the background constantly. The main pylons...
<p>If you want to load parts of a Pylons app, such as the models from outside Pylons, load the Pylons app in the script first:</p> <pre><code>from paste.deploy import appconfig from pylons import config from YOURPROJ.config.environment import load_environment conf = appconfig('config:development.ini', relative_to='....
<p>I'm redacting my response and upvoting the other answer by Ben Bangert, as it's the correct one. I answered and have since learned the correct way (mentioned below). If you really want to, check out the history of this answer to see the wrong (but working) solution I originally proposed.</p>
16,267
<p>I'm looking at parsing a delimited string, something on the order of</p> <p>a,b,c</p> <p>But this is a very simple example, and parsing delimited data can get complex; for instance</p> <p>1,"Your simple algorithm, it fails",True</p> <p>would blow your naiive string.Split implementation to bits. Is there anythin...
<p>I use this to read from a file</p> <pre><code>string filename = @textBox1.Text; string[] fields; string[] delimiter = new string[] {"|"}; using (Microsoft.VisualBasic.FileIO.TextFieldParser parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(filename)) { parser.Delimiters = delimiter; parser.Ha...
<p>I am thinking that a generic framework would need to specify between two things: 1. What are the delimiting characters. 2. Under what condition do those characters not count (such as when they are between quotes).</p> <p>I think it may just be better off writing custom logic for every time you need to do something ...
3,142
<p>Years ago when I was working with C# I could easily create a temporary file and get its name with this function:</p> <pre><code>Path.GetTempFileName(); </code></pre> <p>This function would create a file with a unique name in the temporary directory and return the full path to that file. </p> <p>In the Cocoa API's...
<p>A safe way is to use <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/mkstemp.3.html" rel="nofollow noreferrer">mkstemp(3)</a>.</p>
<p>You could use an <code>NSTask</code> to <code>uuidgen</code> to get a unique file name, then append that to a string from <code>NSTemporaryDirectory()</code>. This won't work on Cocoa Touch. It is a bit long-winded though.</p>
26,531
<p>I'm copying a file from folder A to folder B and then trying to copy the file permissions. Here are the basic steps I'm using:</p> <ol> <li>CopyFile(source, target)</li> <li>GetNamedSecurityInfo(source, GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION)</li> <li>Print source SD using ConvertSecurityDescriptorT...
<p><code>SHFileOperation</code> can copy files together with their security attributes, but from <a href="https://stackoverflow.com/questions/202031/using-shfileoperation-within-a-windows-service">your other question</a> I see you're concerned that this won't work within a service. Maybe the following newsgroup discuss...
<p>Robocopy from the server tools kit <a href="http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&amp;displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&amp;displaylang=en</a><br> Will copy al...
25,197
<p>The best I can come up with for now is this monstrosity:</p> <pre><code>&gt;&gt;&gt; datetime.utcnow() \ ... .replace(tzinfo=pytz.UTC) \ ... .astimezone(pytz.timezone("Australia/Melbourne")) \ ... .replace(hour=0,minute=0,second=0,microsecond=0) \ ... .astimezone(pytz.UTC) \ ... .replace(tzinfo=None) date...
<p>I think you can shave off a few method calls if you do it like this:</p> <pre><code>&gt;&gt;&gt; from datetime import datetime &gt;&gt;&gt; datetime.now(pytz.timezone("Australia/Melbourne")) \ .replace(hour=0, minute=0, second=0, microsecond=0) \ .astimezone(pytz.utc) </code></pre> <p>BUT… ...
<p>Setting the TZ environment variable modifies what timezone Python's date and time functions work with.</p> <pre><code>&gt;&gt;&gt; time.gmtime() (2008, 12, 17, 1, 16, 46, 2, 352, 0) &gt;&gt;&gt; time.localtime() (2008, 12, 16, 20, 16, 47, 1, 351, 0) &gt;&gt;&gt; os.environ['TZ']='Australia/Melbourne' &gt;&gt;&gt; t...
48,833
<p>I need to pass a UUID instance via http request parameter. Spring needs a custom type converter (from String) to be registered. How do I register one?</p>
<p>Please see chapter 5 of the spring reference manual here: <a href="http://static.springframework.org/spring/docs/2.5.x/reference/validation.html#beans-beans-conversion-customeditor-registration" rel="nofollow noreferrer">5.4.2.1. Registering additional custom PropertyEditors</a></p>
<p>Not sure what you are asking?</p> <p>Spring comes with a <a href="http://static.springframework.org/spring/docs/2.5.5/api/org/springframework/beans/factory/config/CustomEditorConfigurer.html" rel="nofollow noreferrer">CustomEditorConfigurer</a> to supply custom String &lt;-> Object converters.</p> <p>To use this, ...
9,350
<p>I'm working on a document "wizard" for the company that I work for. It's a .dot file with a header consisting of some text and some form fields, and a lot of VBA code. The body of the document is pulled in as an OLE object from a separate .doc file.</p> <p>Currently, this is being done as a <code>Shape</code>, rath...
<p>InlineShape is treated as a letter. Hence, the same technique.</p> <pre><code>ThisDocument.Range(15).InlineShapes.AddPicture "1.gif" </code></pre>
<p>My final code ended up using <code>ThisDocument.Paragraphs</code> to get the range I needed. But GSerg pointed me in the right direction of using a <code>Range</code> to get my object where it needed to be.</p>
12,956
<p>I am working on a function to establish the entropy of a distribution. It uses a copula, if any are familiar with that. I need to sum up the values in the array based on which dimensions are &quot;cared about.&quot;</p> <p>Example: Consider the following example...</p> <pre> Dimension 0 (across) _ _ _ _ _ _ _ _ _...
<p>This could have applications. Lets say you implemented a 2D Conway's Game of Life (which defines a 2D plane, 1 for 'alive', 0 for 'dead') and you stored the Games history for every iteration (which then defines a 3D cube). If you wanted to know how many bacteria there was alive over history, you would use the above ...
<p>Actually, by colllapsing the colums you already summed them, so the dimension doesn't matter at all for your example. Did I miss something or did you?</p>
4,318
<p>From a Java program, I need to launch the default browser on a local HTML file, pointed to an anchor inside the file. In Java SE 6, the java.awt.Desktop.browse method will open the file, but will not honor the anchor, so something like the following opens the file at the top, but does not page the browser to the an...
<p>I just solved this another way, because no amount of quoting or spaces in any of these examples worked for me. </p> <p>1 Detect if the file URI has a anchor or query string</p> <p>2 If so, create a temp file <code>File tmpfile = File.createTempFile("apphelp", ".html")</code> with a meta-redirect to the actual fi...
<p>For Windows only, you could try</p> <pre><code>System.exec("cmd.exe start file:///C:/foo/bar.html#anchor") </code></pre>
38,523
<p><code>FromIp</code> contains <code>"192.168.1.1"</code>. I want to get the last number, but I can't figure out what's wrong here:</p> <pre><code> Dim str As String str = FromIP.Text.Substring(FromIP.Text.LastIndexOf("."), FromIP.Text.Length).ToString() MessageBox.Show(FromIP.Text.Length) </code></pre>
<p>Tested code:</p> <pre><code> Dim FromIp As String = "192.168.1.1" Dim str As String str = FromIp.Substring(FromIp.LastIndexOf(".") + 1).ToString() MessageBox.Show(str) </code></pre> <ul> <li>You must add 1 to LastIndexOf to skip the dot</li> <li>There no need put the lenght of the Substring when you...
<p>As far as I remember, Substring takes Start,Stop as parameters.</p> <p>So that would be: <code>txt.Substring(IndexOf, txt.Length - IndexOf)</code> or just with one parameter: Substring(IndexOf + 1)</p>
47,323
<p>After seeing a previous post "<a href="https://stackoverflow.com/questions/335450/making-applications-programmed-in-net-languages-work-on-older-machines">Making Applications programmed in .NET languages work on older machines</a>", I've got to wonder;</p> <p>Are there tools to compile CIL to a binary?</p> <p>If so...
<p>Check this out: <a href="http://msdn.microsoft.com/en-us/library/6t9t5wcf.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/6t9t5wcf.aspx</a></p> <p>And this: <a href="http://www.xenocode.com/Products/Postbuild-for-NET/?AdGroup=Linking&amp;gclid=CNGCo-7zopcCFSYMDQod0giG_A" rel="nofollow norefe...
<p><a href="http://www.dcl.hpi.uni-potsdam.de/research/lego.NET/release.htm" rel="nofollow noreferrer">Lego.NET</a> can create native binaries, but it's still fairly limited.</p>
43,515
<p>When Instantiating a class, Windsor by default treats all public properties of the class as optional dependencies and tries to satisfy them. In my case, this creates a rather complicated circular dependency which causes my application to hang. </p> <p>How can I explicitly tell Castle Windsor that it should not be...
<p>You can use the <a href="http://svn.castleproject.org:8080/svn/castle/trunk/Core/Castle.Core/Attributes/DoNotWireAttribute.cs" rel="nofollow noreferrer">Castle.Core.DoNotWireAttribute</a> attribute to stop a property from being wired up by the IoC container (this is in the Castle.Core assembly, which means your libr...
<p>Posted this on the google groups forum too here: <a href="http://groups.google.com/group/castle-project-devel/browse_thread/thread/43aa513817bd057a" rel="nofollow noreferrer">http://groups.google.com/group/castle-project-devel/browse_thread/thread/43aa513817bd057a</a></p>
21,528
<p>I want to deal with the command line input in Ruby:</p> <pre><code>&gt; cat input.txt | myprog.rb &gt; myprog.rb &lt; input.txt &gt; myprog.rb arg1 arg2 arg3 ... </code></pre> <p>What is the best way to do it? In particular I want to deal with blank STDIN, and I hope for an elegant solution.</p> <pre><code>#!/usr...
<p>Following are some things I found in my collection of obscure Ruby.</p> <p>So, in Ruby, a simple no-bells implementation of the Unix command <code>cat</code> would be:</p> <pre><code>#!/usr/bin/env ruby puts ARGF.read </code></pre> <p><a href="https://ruby-doc.org/core/ARGF.html" rel="noreferrer"><code>ARGF</code></...
<p>It seems most answers are assuming the arguments are filenames containing content to be cat'd to the stdin. Below everything is treated as just arguments. If STDIN is from the TTY, then it is ignored.</p> <pre><code>$ cat tstarg.rb while a=(ARGV.shift or (!STDIN.tty? and STDIN.gets) ) puts a end </code></pre> ...
34,420
<p>Which method makes the most sense for importing a module in python that is version specific? My use case is that I'm writing code that will be deployed into a python 2.3 environment and in a few months be upgraded to python 2.5. This:</p> <pre><code>if sys.version_info[:2] &gt;= (2, 5): from string import Templ...
<p>Always the second way - you never know what different Python installations will have installed. <code>Template</code> is a specific case where it matters less, but when you test for the capability instead of the versioning you're always more robust.</p> <p>That's how I make <a href="http://www.testoob.org" rel="nor...
<p>I would probably argue that the second one would be preferable. Sometimes, you can install a module from a newer version of python into an older one. For example, wsgiref comes with Python 2.5, but it isn't entirely uncommon for it to be installed into older versions (I think it will work with python 2.3 up).</p>
44,519
<p>What is the easiest way to merge XML from two distinct DOM Documents? Is there a way other than using the Canonical <a href="http://support.microsoft.com/kb/311530" rel="nofollow noreferrer">DataReader</a> approach and then messing with the outputted DOM. What I basically want is to AppendChild to XmlElements with...
<p>You can use the XmlDocument.ImportNode method to copy a node from a XmlDocument to another.</p>
<p>You might be interested in <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.importnode.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.importnode.aspx</a>. But take a close look at the "The following table describes the specific behavior for each ...
8,189
<p>The following PHP code snippet uses GD to resize a browser-uploaded PNG to 128x128. It works great, except that the transparent areas in the original image are being replaced with a solid color- black in my case. </p> <p>Even though <code>imagesavealpha</code> is set, something isn't quite right.</p> <p>What's the...
<pre><code>imagealphablending( $targetImage, false ); imagesavealpha( $targetImage, true ); </code></pre> <p>did it for me. Thanks ceejayoz.</p> <p>note, the target image needs the alpha settings, not the source image.</p> <p>Edit: full replacement code. See also answers below and their comments. This is not guarant...
<p>Here is my total test code. It works for me</p> <pre><code>$imageFileType = pathinfo($_FILES["image"]["name"], PATHINFO_EXTENSION); $filename = 'test.' . $imageFileType; move_uploaded_file($_FILES["image"]["tmp_name"], $filename); $source_image = imagecreatefromjpeg($filename); $source_imagex = imagesx($source_im...
5,217
<p>I'm developing a poker game in C#. At the moment I'm trying to get the players hand score using <code>RegEx</code>. I search the string (composed of the cards suit and number) and look for suits or numbers to match the <code>RegEx</code>. If i get 2 matches then the player has a pair, 3 matches he has 3 of a kind. <...
<p>I do not think that a regex is the appropriate way to deal with this. You probably should be using a more sophisticated representation of a hand than a string.</p>
<p>Using a string to represent the hand seems like a poor decision. My recommendation would be to use an Enum to represent the Suit and another to represent the numeric value of the card.</p>
30,257
<p>I have a website that I've just uploaded onto the Internet. When I browse to the site using Firefox 3.0.1 on Ubuntu I don't see the favicon; Firefox 3.0.1 on WinXP does display it.</p> <p><strong>Why</strong> isn't the favicon displaying under Ubuntu? It's a favicon.ico file in the root directory, not referenced...
<p>Previously, there was no favicon. The browser cached the lack of favicon. <a href="http://pcsupport.about.com/od/maintenance/ht/clearcacheff.htm" rel="noreferrer">Clear the Firefox cache</a>, and all is well.</p>
<p>Try taking a look at this <a href="https://stackoverflow.com/questions/6642/perfect-way-to-use-favicons">previous Question</a>, which shows you must put two meta tags in your html in order for it to work across all browsers and operating systems.</p>
2,846
<p>Is it possible to use any chart modules with wxpython? And are there any good ones out there?</p> <p>I'm thinking of the likes of PyCha (<a href="http://www.lorenzogil.com/projects/pycha/" rel="noreferrer">http://www.lorenzogil.com/projects/pycha/</a>) or any equivalent. Many modules seem to require PyCairo, but I ...
<p>I recently revisited <a href="http://matplotlib.sourceforge.net/index.html" rel="nofollow noreferrer">matplotlib</a>, and am pretty happy with the results. If you're on windows, there are windows installers available to make your installation process a little less painful.</p> <p>One potential drawback though is th...
<p>matplotlib does embed quite well in <a href="http://www.scipy.org/Cookbook/Matplotlib/EmbeddingInWx" rel="nofollow noreferrer">wxpython</a>. I have only used it in Tkinter, which went smoothly for me. I like the optional toolbar that allows direct manipulation of the plot (resizing and panning and such)</p>
46,707
<p>I needed to know if typical UV curing resins, such as the ones from Anycubic, can withstand solar radiation over extended periods of time with little to no degradation. It has been quite difficult to find information about the subject online, so I'm wondering whether anyone here has experience here to share.</p>
<p>What seems to be a difficulty is the stabilizers for plastic absorb UV. So if added to UV resin, they probably greatly increase the exposure time needed.</p> <p>The following show characteristics of some plastics, taken from <a href="https://www.coleparmer.com/tech-article/uv-properties-of-plastics" rel="nofollow n...
<p>Sunlight contains the full spectrum of electromagnetic radiation, including the wavelength to photoinitiate your resin. Most UV-curable materials are kept in opaque containers for this reason. The extent to which your material is crosslinked will depend on your material and how much sunlight it receives.</p>
1,879
<p>A project I'm working on at the moment involves refactoring a C# Com Object which serves as a database access layer to some Sql 2005 databases.</p> <p>The author of the existent code has built all the sql queries manually using a string and many if-statements to construct the fairly complex sql statement (~10 joins...
<p>I used C# and Linq to do something similar to get log entries filtered on user input (see <a href="https://stackoverflow.com/questions/11194/conditional-linq-queries">Conditional Linq Queries</a>):</p> <pre><code>IQueryable&lt;Log&gt; matches = m_Locator.Logs; // Users filter if (usersFilter) matches = matches...
<p>You may want to consider LINQ or an O/R Mapper like this one: <a href="http://www.llblgen.com/" rel="nofollow noreferrer">http://www.llblgen.com/</a> </p>
8,851
<p>I have a c++ application which logs to some file using log4cxx (RollingFile appender). I want to log into the same file, at the same time, from another module written in c#; so i configured log4net to use the same file, but i can't get the new messages in. If i deactivate the c++ logging, i can see c# messages. So i...
<p>I think that you might run into concurrency and contention problems no matter what configuration you use as long as you are attempting to have two different processes log to the same file.</p> <p>You should look into sending log events from both processes to a third, centralized location - take a look at <a href="h...
<p>Even if the question is quite old (and marked as answered) and you're probably already finished with your project:</p> <p>log4net and log4cxx are distinct logging framworks that don't know of each other so you can't configure them to write to the same file. Only one of the framworks will have the file open for writ...
27,326
<p>Tools like Selenium are good for testing user interactions on the web UI. However, I was curious what are people approaches for strictly testing and verifying that web pages are rendered correctly across a set of browsers?</p> <p>Is this even possible?</p>
<p>May I recommend <a href="http://browsershots.org/" rel="nofollow noreferrer">browsershots</a> where you can submit pages and have them rendered out in a variety of browsers with various things set on or off such as Flash and JavaScript. At the end of the day you will still want to install FF, IE6-8, Opera and Safari...
<p>Manually?</p> <p>I do not see an alternative if you want strict testing. Just install as many different browsers as possible and test in all of them. Of course this includes different versions of most popular browsers, and you need to check on Windows, Linux and Macintosh.</p>
12,525
<p>I was just browsing a forum and someone asked about a PHP file they had found on the web. It has several spots like this in the code:</p> <p><code>if ($REMOTE_ADDR == "") $ip = "no ip"; else $ip = getHostByAddr($REMOTE_ADDR);</code></p> <p>I have always thought brackets are needed to enclose what you want to do i...
<p>you can do if else statements like this:</p> <pre><code>&lt;?php if ($something) { echo 'one conditional line of code'; echo 'another conditional line of code'; } if ($something) echo 'one conditional line of code'; if ($something) echo 'one conditional line of code'; echo 'a NON-conditional line of code';...
<pre><code>brackets are needed to enclose what you want to do if the condition is true </code></pre> <p>I can't think of any language that requires this</p>
49,974
<p>I'm trying to write a stored procedure to select employees who have birthdays that are upcoming. </p> <p><code>SELECT * FROM Employees WHERE Birthday &gt; @Today AND Birthday &lt; @Today + @NumDays</code></p> <p>This will not work because the birth year is part of Birthday, so if my birthday was '09-18-1983' that...
<p><em>Note: I've edited this to fix what I believe was a significant bug. The currently posted version works for me.</em></p> <p>This should work after you modify the field and table names to correspond to your database.</p> <pre><code>SELECT BRTHDATE AS BIRTHDAY ,FLOOR(DATEDIFF(dd,EMP.BRTHDATE,GETDATE()) / 365...
<p>Better, Add the difference in years to the BIRTHDAY date, to make everything this year, and then do your compares</p> <pre><code>SELECT * FROM Employees WHERE DATEADD ( year, YEAR(@Today) - YEAR(@Birthday), birthday) BETWEEN @Today AND @EndDate </code></pre>
10,915
<p>I have an entity that contains many of itself, how do I map this in LINQ to SQl such that it does not do an infinite loop of getting e1 then all its children then their parents (e1) then its children and repeat? Now I know I can do this if I set the child property to false, however that is the most important propert...
<p>In the designer, select a property on an entity in the diagram, and in the <em>Code Generation</em> section in the properties window, set <strong>Delay Loaded</strong> to <em>True</em> .</p> <p>See <a href="http://www.davidhayden.com/blog/dave/archive/2007/08/05/LINQToSQLLazyLoadingPropertiesSpecifyingPreFetchWhenN...
<p>This site is not good for my pre-existing biases, turns out <em>this one</em> was an ill-configured route not lazy/eager loading</p>
7,643
<p>I want to I check whether a string is in ASCII or not.</p> <p>I am aware of <code>ord()</code>, however when I try <code>ord('é')</code>, I have <code>TypeError: ord() expected a character, but string of length 2 found</code>. I understood it is caused by the way I built Python (as explained in <a href="http://docs...
<pre><code>def is_ascii(s): return all(ord(c) &lt; 128 for c in s) </code></pre>
<p>I use the following to determine if the string is ascii or unicode:</p> <pre><code>&gt;&gt; print 'test string'.__class__.__name__ str &gt;&gt;&gt; print u'test string'.__class__.__name__ unicode &gt;&gt;&gt; </code></pre> <p>Then just use a conditional block to define the function:</p> <pre><code>def is_ascii(i...
23,854
<p>NDoc has an XML element <strong>inheritdoc</strong> which allows you to inherit documentation of a member from the parent class (or an implemented interface). However, Visual Studio (i.e. the C# compiler) does not understand this tag and complains about the documentation not being present or complete. So does StyleC...
<p>One alternative is to use <a href="http://www.roland-weigelt.de/ghostdoc/" rel="noreferrer">GhostDoc</a> - an add-in for Visual Studio that automatically generates comments for you. This duplicates the XML description of course, which is part of what you're trying to avoid - but at least it does it automatically for...
<p>I built a command line tool to post-process the XML documentation files to add support for the &lt;inheritdoc/&gt; tag.</p> <p>It doesn't help with Intellisense in source code but it does allow the modified XML documentation files to be included in a NuGet package and therefore works with Intellisense in referenced...
40,126
<p>I'm by no means a sysadmin so please correct me if I'm wrong.</p> <p>I want to run aspnet_regiis.exe -s. This requires the metabase path of my website.</p> <p>How do I find this metabase path?</p>
<p>Just run aspnet_regiis.exe -lk to see a list of the registered applications, their metabase paths and the version of the .NET framework installed for this application.</p> <p>Also, here are a couple of links that you can use to find the metabase path:</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/m...
<p>For versions of Windows higher than Vista, try <a href="http://www.iis.net/learn/get-started/getting-started-with-iis/getting-started-with-appcmdexe" rel="nofollow">appcmd</a>, with the "list site" commands:</p> <blockquote> <p>%WindowsDirectory%\system32\inetsrv\appcmd list site</p> </blockquote> <p>This should...
32,705
<p>I plan to have 2 projects. 1. mbtech.crm.mvc 2. mbtech.crm.tests</p> <p>I will have a solution named mbtech.crm</p> <p>What is the best way to set these up so that I can track them in Subversion?</p> <p>Option 1 (then where does my solution file go)?<br> - mbtech.crm.mvc<br> &nbsp;&nbsp; - tags<br> &nbsp;&nbsp; ...
<p>Option 2 would be my choice, they're two parts of the same solution, so it doesn't make much sense to separate them. I can't see any reason why you'd branch your code but not your tests, or vice versa.</p>
<p>If the projects are strong related, then you should probably use the same trunk. If they are independent of each other, or have just a shallow relationship, then you would probably be better of with different trunks.</p>
28,623
<p>When using something like <code>object.methods.sort.to_yaml</code> I'd like to have irb interpret the \n characters rather than print them. </p> <p>I currently get the following output:</p> <pre><code>--- \n- "&amp;"\n- "*"\n- +\n- "-"\n- "&lt;&lt;"\n- &lt;=&gt;\n ... </code></pre> <p>What I'd like is something s...
<p>Prefix your output with <code>puts</code>:</p> <pre><code>&gt; puts object.methods.sort.to_yaml --- - "&amp;" - "*" - + - "-" - "&lt;&lt;" - &lt;=&gt; =&gt; nil </code></pre>
<p>That's just irb -- I don't think you can control the <code>return</code> formatting.</p> <p>You can still use <code>print</code> or <code>puts</code> to display it as you want.</p>
28,351
<p><strong>Update</strong>: Looks like the query does not throw any timeout. The connection is timing out.</p> <p>This is a sample code for executing a query. Sometimes, while executing time consuming queries, it throws a timeout exception.</p> <p>I <strong>cannot</strong> use any of these techniques: 1) Increase tim...
<p>Since you are using ExecuteNonQuery which does not return any rows, you can try this polling based approach. It executes the query in an asyc manner (without callback) but the application will wait (inside a while loop) until the query is complete. From <a href="http://msdn.microsoft.com/en-us/library/ca56w9se(VS.80...
<pre><code>command.CommandTimeout *= 2; </code></pre> <p>That will double the default time-out, which is 30 seconds.</p> <p>Or, put the value for CommandTimeout in a configuration file, so you can adjust it as needed without recompiling.</p>
13,112
<p>I'm having this problem, same as ever, but never try to find the <em>right</em> solution</p> <p>code:</p> <pre><code> &lt;div id="ListOfTextAndPhotos"&gt; &lt;div style="border-bottom: solid 1px silver;"&gt; &lt;img src="photo.jpg" style="float: left"&gt; Some text about the photo &...
<p>The more traditional way (other than clearing) is to set the overflow property of the containing div to hidden.</p> <pre><code>&lt;div style="border-bottom: solid 1px silver; overflow: hidden;"&gt; &lt;img src="photo3.jpg" style="float: left"&gt; &lt;div&gt;Some text about the photo3&lt;/div&gt; &lt;/di...
<p>I had a similar problem here where my images were overflowing my div:</p> <p>&lt; div id="offer"> &lt; div class="inner"> &lt; img src="offer.png" alt=""></p> <p>where i had to have my image float:right; so that the text would appear on the left side of it and fill the space. I couldn't figure out why the hec...
48,252
<p>I want to separate concerns here. Create and embed all the UI logic for the Custom XML designer, object model, validations etc in to a separate assembly. Then the Package framework should only register the designer information and ask for a UI Service and everything works magically.</p> <p>This way I don't need to ...
<p>I've created a VSPackage that loads an editor. The Editor sits in a separate assembly and implements an interface that I defined. The VSPackage works with the interface, so any changes I make to the editor (and its assembly) does not affect the VSPackage as long as I don't change the interface.</p>
<p>I prefer the <a href="http://msdn.microsoft.com/en-us/magazine/cc188690.aspx#S1" rel="nofollow noreferrer">Model View Presenter</a> pattern</p>
19,157
<p>I've been spoiled by Visual studio 2008 and Eclipse and have to do a little maintainence work on a VB6 app.</p> <p>Does anyone know of an alternative/ updated IDE for VB6?</p> <p>A rewrite is not an option I'm just fixing a couple of bugs and it's a big codebase.</p>
<p>I have never heard of an alternative IDE for Vb6. However, these two (free) VB6 add-ins are indispensable and will make your life easier - especially if there is a lot of code. They are equally effective for VBA in Microsoft Office.</p> <p><strong>MZ-Tools</strong>: provides a superb collection of IDE tools - findi...
<p>Yeah, no alternative IDEs to VB6 afaik. But one indispensable add-in I used was CodeHelp. It gives you tabs! for the windows, easy tab ordering, fullscreen switcher and maybe a mousewheel add-in. Check it out from the <a href="http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=62468&amp;lngWId=1" rel=...
28,021
<p>When you send an email using C# and the System.Net.Mail namespace, you can set the "From" and "Sender" properties on the MailMessage object, but neither of these allows you to make the MAIL FROM and the from address that goes into the DATA section different from each other. MAIL FROM gets set to the "From" property...
<p><code>MailMessage.Sender</code> will always insert a <code>Sender</code> header (interpreted as <em>on behalf of</em> in your e-mail client). </p> <p>If you use the <code>Network</code> delivery method on the <code>SmtpClient</code>, <code>.Sender</code> will also change the sender in the envelope. Using the <code>...
<p>Do you mean this?:</p> <pre><code>//create the mail message MailMessage mail = new MailMessage(); //set the addresses mail.From = new MailAddress("me@mycompany.com"); mail.To.Add("you@yourcompany.com"); //set the content mail.Subject = "This is an email"; mail.Body = "this is a sample body with html in it....
7,501
<p>You do you manage the same presenter working with different repositories using the MVP pattern? </p> <p>I just have multiple constructor overloads and the presenter simply uses the one that is suitable for the scenario. </p> <pre><code>AddCustomerPresenter presenter = new AddCustomerPresenter(this,customerReposito...
<p>Why not have</p> <pre><code>IRepository { /* .. */ } CustomerRepository : IRepository { /* .. */ } ArchiveRepository : IRepository { /* .. */ } </code></pre> <p>and then</p> <pre><code>AddCustomerPresenter { IRepository Store {get;set;} public AddCustomerPresenter(IRepository store) { /*...*/ } /*...*/ } </code><...
<p>Why not have</p> <pre><code>IRepository { /* .. */ } CustomerRepository : IRepository { /* .. */ } ArchiveRepository : IRepository { /* .. */ } </code></pre> <p>and then</p> <pre><code>AddCustomerPresenter { IRepository Store {get;set;} public AddCustomerPresenter(IRepository store) { /*...*/ } /*...*/ } </code><...
19,190
<p>Program followed by output. Someone please explain to me why 10,000,000 milliseconds from Jan 1, 1970 is November 31, 1969. Well, someone please explain what's wrong with my assumption that the first test should produce a time 10,000,000 milliseconds from Jan 1, 1970. Numbers smaller than 10,000,000 produce the s...
<p>The dates you print from <code>Calendar</code> are local to your timezone, whereas the epoch is defined to be midnight of 1970-01-01 in UTC. So if you live in a timezone west of UTC, then your date will show up as 1969-12-31, even though (in UTC) it's still 1970-01-01.</p>
<p>You can figure out yourself if you change your first <code>c.setTimeInMillis(l);</code> in <code>c.clear();</code></p>
32,973
<p>When you call the <code>object.__repr__()</code> method in Python you get something like this back: </p> <blockquote> <pre><code>&lt;__main__.Test object at 0x2aba1c0cf890&gt; </code></pre> </blockquote> <p>Is there any way to get a hold of the memory address if you overload <code>__repr__()</code>, other then ca...
<p>The <a href="https://docs.python.org/2/library/functions.html#id" rel="noreferrer">Python manual</a> has this to say about <code>id()</code>:</p> <blockquote> <p>Return the "identity'' of an object. This is an integer (or long integer) which is guaranteed to be unique and constant for this object during its...
<p>While it's true that <code>id(object)</code> gets the object's address in the default CPython implementation, this is generally useless... you can't <i>do</i> anything with the address from pure Python code.</p> <p>The only time you would actually be able to use the address is from a C extension library... in which...
14,768
<p>I am currently working on a web application that uses PHP and MySQL, but I do not have shell access to the server (working on that problem already...). Currently, I have source control with subversion on my local computer and I have a database on the local computer that I make all changes to. Then, once I've teste...
<p>I'm using <a href="http://weex.sourceforge.net/" rel="nofollow noreferrer">Weex</a> to synchronize a server via FTP. Weex is basically a non-interactive FTP client that automatically uploads and deletes files/directories on the remote server. It can be configured to not upload certain paths (like SVN directories), a...
<p>I'm using <a href="http://weex.sourceforge.net/" rel="nofollow noreferrer">Weex</a> to synchronize a server via FTP. Weex is basically a non-interactive FTP client that automatically uploads and deletes files/directories on the remote server. It can be configured to not upload certain paths (like SVN directories), a...
34,795
<p>Is there any good alternative to ASpell? It's nice open source, but haven't been updated for a while. The performance is not too good and I am having trouble creating a custom worklist with non-alpha characters.</p>
<p><a href="http://hunspell.sourceforge.net/" rel="noreferrer">Hunspell</a>. It's what Firefox uses for its spellchecker.</p>
<p>There is also <a href="http://ficus-www.cs.ucla.edu/geoff/ispell.html" rel="nofollow noreferrer" title="International Ispell">Ispell</a>, might not be faster or better maintained, but it supports international characters. I don't know how it compares to Hunspell.</p>
14,099
<p>I've got a PHP command line program running. And I want to connect to a mysql shell straight from PHP. I've done this before in Python using os.execvp But I can't get the same thing to work in PHP.</p> <p>I've tried the following functions:</p> <ul> <li>system</li> <li>passthru</li> <li>exec</li> <li>shell_exec</l...
<p>If you want shell commands to be interactive, use:</p> <pre><code>system("mysql -uroot -p db_name &gt; `tty`"); </code></pre> <p>That will work for most cases, but will break if you aren't in a terminal.</p>
<p>Give MySQL a script to run that's separate from the PHP script:</p> <pre><code>system('mysql -u root -pxxxx db_name &lt; script.mysql'); </code></pre>
34,358
<p>What is the best way to check for the existence of a session variable in ASP.NET C#? </p> <p>I like to use <code>String.IsNullOrEmpty()</code> works for strings and wondered if there was a similar method for <code>Session</code>. Currently the only way I know of is:</p> <pre><code> var session; if (Session["var...
<p>To follow on from what others have said. I tend to have two layers:</p> <p><strong>The core layer. This is within a DLL that is added to nearly all web app projects</strong>. In this I have a SessionVars class which does the grunt work for Session state getters/setters. It contains code like the following:</p> <pr...
<p>Are you using .NET 3.5? Create an IsNull extension method:</p> <pre><code>public static bool IsNull(this object input) { input == null ? return true : return false; } public void Main() { object x = new object(); if(x.IsNull) { //do your thing } } </code></pre>
29,083
<p>I am trying to get my continuous integration to create build the smart device cab project from within msbuild on the command line. Everything that I have found says to use the inf file (with cabwiz) created when you build the project from within visual studio. Is there a way to create the inf using the .vddproj file...
<p>Your best bet is either to run devenv.exe (or devenv.com) from the msbuild task, or to steal the INF that Visual Studio generates and use it to run cabwiz.exe from the msbuild task.</p> <p>MVP Discussion: <a href="http://social.microsoft.com/Forums/en-US/csharpide/thread/a3caae81-fd79-45a9-ac38-f471e30e5b2a" rel=...
<p>Are you asking how to create the cab file or how to include it in your project? You could create the <a href="http://www.sundialsoft.freeserve.co.uk/cabinfo.htm" rel="nofollow noreferrer">inf</a> then add the <a href="http://msdn.microsoft.com/en-us/library/aa924359.aspx" rel="nofollow noreferrer">command line</a> t...
47,556
<p>Background: I'm currently debugging an application written over a custom-built GUI framework in C++. I've managed to pin down most bugs, but the bugs I'm having the most trouble with tend to have a common theme. All of them seem to be to do with the screen refreshing, redrawing or updating to match provided data. Th...
<p>I agree with dual monitors or even remote debugging to reduce interfering with the messages.</p> <p>I also highly recommend Spy utilities. These let you see what messages are being sent in the system. One such program is Winspector. <a href="http://www.windows-spy.com/" rel="noreferrer">http://www.windows-spy.com...
<p>Having a dual screen really help when debugging refresh/redraw problem for Windows controls and UI.</p> <p>Having the application on the second screen will not have the debugger generate "invalidate" on the main UI screens when it breaks for a debugging breakpoint.</p> <p>If you cannot have a second screen, try t...
49,536
<p>Today I discovered something that makes me sad: objects of type System.Generic.Collections.List don't have a number of the useful extension methods I've come to love, such as Find, FindAll, FindIndex, Exists, RemoveAll, etc. </p> <p>The object browser in VS2008 shows that those methods exist in the mscorlib version...
<p>What's likely happening here is that Object Browser is resolving to the normal 2.0 mscorlib instead of the version that is used for silverlight.</p> <p>I don't find it suprising that the Find extension method is missing for a SilverLight app. The .Net framework for SilverLight is stripped down pretty far in order ...
<p>just reference the System.Core assembly if you haven't yet and do a</p> <pre><code>using System.Linq; </code></pre> <p>and for any IEnumerable, you will have lots of extension methods that can do the stuff you need and more.</p> <p>Microsoft obviously wants to keep the Silverlight runtime small for download, thus...
43,904
<p>How can I open a synchronous dialog in Flex? I need to call a function from an External Interface (JavaScript) that will open a simple dialog in the Flex application and returns an value according to the button the user has clicked (OK/Cancel).</p> <p>So it should by a synchronous call to a dialog, i.e. the call wa...
<p>You can't do that in Flex. As David mentioned, Flex is single-threaded, so you can't have your function block while the dialog is being processed.</p> <p>Your best bet might be to use a Javascript popup. You'll have a lot less control over the window, but it should behave the way you want (blocking the function u...
<p>You can fake a synchronous dialog in flex by popping up a dialog then disabling everything in the background. You can see this in action if you do <code>Alert.show("Hello World");</code> in an application. The background will grey out and the user won't be able to click on any UI in the background. The app will "wai...
22,763
<p>I am looking at embedding Lua in a C++ application I am developing. My intention is to use Lua to script what ordered operation(s) to perform for some given input, ie. receive a new work item in c++ program, pass details to Lua backend, Lua calls back into c++ to carry out necessary work, returns finished results. <...
<p>If I recall correctly, light userdata is actually just a pointer. They all share the same metatable. They are mostly used to pass around addresses of C data.<br> Full userdata is probably closer of what you need if you must access it from the Lua side. Their metatable would allow you to access it like it was a regul...
<p>If I where you, I would pass around a reference to the struct and then let Lua call C functions to modify it. This also means that you can upgrade the system with less hassle than if Lua has to know all the details of the underlying system.</p>
35,864
<p>I'd like to create a tree structure from JSON, but with multiple columns that can be sorted. I've seen lots of implementations of trees and grids but never one mixed.</p> <p>Does anyone know of a plugin or feature for any Javascript toolkit that can make this happen so I don't have to re-invent the wheel here?</p>
<p>This seems pretty nice: <a href="http://www.max-bazhenov.com/dev/ux.maximgb.treegrid/index.html" rel="noreferrer">http://www.max-bazhenov.com/dev/ux.maximgb.treegrid/index.html</a></p> <p>Uses ExtJS, which has some licensing limitations you have to consider.</p>
<p>Here is an "official" example as well (top grid on the page), using the RowExpander UX.</p> <p><a href="http://extjs.com/deploy/dev/examples/grid/grid3.html" rel="nofollow noreferrer">http://extjs.com/deploy/dev/examples/grid/grid3.html</a></p>
23,501
<p>I have a backup server that automatically backs up my live site, both files and database.</p> <p>On the live site, the text looks fine, but when you view the mirrored version of it, it displays '?' within some of the text. This text is stored within the news database table.</p> <p>Here is a screenshot of it being on...
<p>The following articles will be useful:</p> <p><em><a href="http://dev.mysql.com/doc/refman/5.0/en/charset-syntax.html" rel="nofollow noreferrer">10.3 Specifying Character Sets and Collations</a></em></p> <p><em><a href="http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html" rel="nofollow noreferrer">10.4 Co...
<p>Check the character set being emitted by your mirrored server. There appears to be a difference from that to the main server -- the live site appears to be outputting Unicode, where the mirror is not. Also, it's usually a good idea to scrub Unicode characters in your incoming content and replace them with their appr...
29,824
<p>What's the query syntax to determine the exact version number of the MySQL server software?</p>
<p>You can use <a href="http://dev.mysql.com/doc/refman/5.0/en/show-variables.html" rel="noreferrer"><code>SHOW VARIABLES</code></a>:</p> <p><code>SHOW VARIABLES WHERE Variable_name = 'version';</code></p>
<p>Besides the already mentioned solutions you can simply see the version if you type <code>mysql</code> in your shell. You will get something like this:</p> <pre><code>[nikola@localhost]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 386102 Server version: 5.1.61 Source d...
43,676
<p>Trying to create my first iPhone app that would play back audio. When I try to set up playback, messages like these appear in gdb:</p> <blockquote> <p>=shlibs-removed,shlib-info=[num="54",name="AudioIPCPlugIn",kind="B",dyld-addr="0x2c2000",reason="dyld",requested-state="E",state="E",path="/System/Library/Extensio...
<p>Those are informational messages from the system which let you know when a dynamic library gets unloaded from your executable. I presume that they occur in this case because you are perhaps doing a bit too much destructing (ie, unloading bundles, etc.) when you try to shut down your app's connection to CoreAudio.</...
<p>AFAIK, those are information message about unloaded dynamic libraries, i don't think it denotes any problem or error.</p>
21,861
<p>I am using svn tortoise to checkout a maven project from a repository, I then open eclispe, and use the m2eclipse plugin to import a maven project. The maven projeect comes in okay, and I can build it fine.</p> <p>The problem is that eclipse using subversive, isn't marking files/ resources as being in source contr...
<p>Did you set up your project for team sharing (right click on project->Team->Share project)? If I remember correctly that should detect the existing .svn folders an enables version control inside of eclipse.</p>
<p>You might wanna try using <a href="http://subclipse.tigris.org/" rel="nofollow noreferrer">Subclipse</a>. It's the Eclipse plug-in for Subversion and is really good. I've also found that interacting with a SVN repository with Tortoise while also having Eclipse open and accessing the same repository causes problems....
18,026
<p>I have a small local network. Only one of the machines is available to the outside world (this is not easily changeable). I'd like to be able to set it up such that ssh requests that don't come in on the standard port go to another machine. Is this possible? If so, how?</p> <p>Oh and all of these machines are runni...
<p>Another way to go would be to use ssh tunneling (which happens on the client side).</p> <p>You'd do an ssh command like this:</p> <pre><code>ssh -L 8022:myinsideserver:22 paul@myoutsideserver </code></pre> <p>That connects you to the machine that's accessible from the outside (myoutsideserver) and creates a tunne...
<p>You can use Port Fowarding to do this. Take a look here:</p> <p><a href="http://portforward.com/help/portforwarding.htm" rel="nofollow noreferrer">http://portforward.com/help/portforwarding.htm</a></p> <p>There are instructions on how to set up your router to port forward request on this page:</p> <p><a href="htt...
6,705
<p>I have the following template</p> <pre><code>&lt;h2&gt;one&lt;/h2&gt; &lt;xsl:apply-templates select="one"/&gt; &lt;h2&gt;two&lt;/h2&gt; &lt;xsl:apply-templates select="two"/&gt; &lt;h2&gt;three&lt;/h2&gt; &lt;xsl:apply-templates select="three"/&gt; </code></pre> <p>I would like to only display the headers (one,tw...
<pre><code>&lt;xsl:if test="one"&gt; &lt;h2&gt;one&lt;/h2&gt; &lt;xsl:apply-templates select="one"/&gt; &lt;/xsl:if&gt; &lt;!-- etc --&gt; </code></pre> <p>Alternatively, you could create a named template,</p> <pre><code>&lt;xsl:template name="WriteWithHeader"&gt; &lt;xsl:param name="header"/&gt; &lt;xsl:pa...
<p>I like to exercise the <em>functional</em> aspects of XSL which lead me to the following implementation:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; </code></pre> <p> </p> <pre><code>&lt;!-- test data inlined --&gt; &lt;test&gt; &lt;one&gt;Content 1&lt;/one&gt; &lt;two&gt;Content 2&lt;...
23,715
<p>In C#, I want to initialize a string value with an empty string.</p> <p>How should I do this? What is the right way, and why?</p> <pre><code>string willi = string.Empty; </code></pre> <p>or</p> <pre><code>string willi = String.Empty; </code></pre> <p>or</p> <pre><code>string willi = ""; </code></pre> <p>or w...
<p><strong>Use whatever you and your team find the most readable.</strong></p> <p>Other answers have suggested that a new string is created every time you use <code>""</code>. This is not true - due to string interning, it will be created either once per assembly or once per AppDomain (or possibly once for the whole p...
<p>If you want to prank someone, put <code>&quot;‍&quot;</code> into their code. This is not the empty string, it’s <code>&quot;\u200D&quot;</code>. You cannot fool someone using <code>string.Empty</code>.</p>
32,945
<p>I've got an existing site I'm taking over, and right now it stores, in a session variable, the id of the currently logged in user (if logged in at all -- otherwise I'm sure it is empty string or null or something).</p> <p>The client now wants, after someone is logged in, to "keep" them logged in on that computer fo...
<p>This is how I do it. I actually have a cookie that holds their login and password, this way I can automatically log them in should they not be logged in. I expire the cookie after a couple of days of inactivity. The downside is that <strong>everyone</strong> forgets their password because the only time they reall...
<p>That's the way I do it, but the problem with it (at least I think its a problem) is that when you store the username and password in a cookie there is not any encrypting when you add the cookie. If you look at the cookies in your browser the username and password are displayed there plain as day. Is it possible to ...
45,134
<p>I'm looking for effective way to sort albums with songs. I have around 10000 and growing albums with approx 10 songs in every album. So that means 100000 files. </p> <p>Now I do not want to store all folders (albums) in one main folder, but I'm looking for a better way to store it. All folders are hierarchy equal, ...
<p>Write a content management program into which you can load your mp3s, have it move the file to a folder in its structure, and write an entry to a database.</p> <p>Have the database store the information, including physical path.</p> <p>Query against the database when you are searching, and have your management pro...
<p>Assuming your trying to access these from the file system and not through some other software, you'd be best served to create a hierarchy that can be easily navigated. I would use the initials as you suggested.</p> <p>Group them by first letter, then second letter, as deep as you need to get small-ish groups. You...
37,131
<p>As being quite a newbie in linux, I have the follwing question. I have list of files (this time resulting from svn status) and i want to create a script to loop them all and replace tabs with 4 spaces.</p> <p>So I want from </p> <pre><code>.... D HTML/templates/t_bla.tpl M HTML/templates/t_list_markt.tpl...
<p>You can use this command:</p> <pre><code>svn st | cut -c8- | xargs ls </code></pre> <p>This will cut the first 8 characters leaving only a list of file names, without Subversion flags. You can also add <code>grep</code> before <code>cut</code> to filter only some type of changes, like <code>/^M/</code>. <code>xarg...
<p>Not quite what you're asking, but perhaps you should be looking into commit hooks in subversion?</p> <p>You could create a hook to block check-ins of any code that contains tabs at the start of a line, or contains tabs at all.</p> <p>In the repo directory on your subversion server there'll be a directory called ho...
36,888
<p>I am trying to write a C++ program that takes the following inputs from the user to construct rectangles (between 2 and 5): height, width, x-pos, y-pos. All of these rectangles will exist parallel to the x and the y axis, that is all of their edges will have slopes of 0 or infinity.</p> <p>I've tried to implement w...
<pre><code>if (RectA.Left &lt; RectB.Right &amp;&amp; RectA.Right &gt; RectB.Left &amp;&amp; RectA.Top &gt; RectB.Bottom &amp;&amp; RectA.Bottom &lt; RectB.Top ) </code></pre> <p>or, using Cartesian coordinates </p> <p>(With X1 being left coord, X2 being right coord, <strong>increasing from left to right</s...
<p>I have implemented a C# version, it is easily converted to C++.</p> <pre><code>public bool Intersects ( Rectangle rect ) { float ulx = Math.Max ( x, rect.x ); float uly = Math.Max ( y, rect.y ); float lrx = Math.Min ( x + width, rect.x + rect.width ); float lry = Math.Min ( y + height, rect.y + rect.height ...
39,406
<p>Is there a way to collect (e.g. in a List) multiple 'generic' objects that don't share a common super class? If so, how can I access their common properties?</p> <p>For example:</p> <pre><code>class MyObject&lt;T&gt; { public T Value { get; set; } public string Name { get; set; } public MyObject(string n...
<p>I don't think it is possible in C#, because MyObject is not a baseclass of MyObject. What I usually do is to define an interface (a 'normal' one, not generic) and make MyObject implement that interface, e.g.</p> <pre><code>interface INamedObject { string Name {get;} } </code></pre> <p>and then you can use the ...
<p>The best way would be to add a common base class, otherwise you can fall back to reflection.</p>
7,473
<p>The System.Diagnostics.EventLog class provides a way to interact with a windows event log. I use it all the time for simple logging...</p> <pre><code>System.Diagnostics.EventLog.WriteEntry("MyEventSource", "My Special Message") </code></pre> <p>Is there a way to set the user information in the resulting event log...
<p>Toughie ...</p> <p>I looked for a way to fill the user field with a .NET method. Unfortunately there is none, and you must import the plain old Win32 API [ReportEvent function](<a href="http://msdn.microsoft.com/en-us/library/aa363679(VS.85).aspx)" rel="noreferrer">http://msdn.microsoft.com/en-us/library/aa363679(V...
<p>You need to add it yourself into the event message.</p> <p>Use the System.Security.Principal namespace to get the current identity of the thread logging the event.</p>
17,732