instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I basically created some tables to play around with: I have Two main tables, and a Many-Many join table. Here is the DDL: (I am using HSQLDB)</p> <pre><code>CREATE TABLE PERSON ( PERSON_ID INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, NAME VARCHAR(50), MAIN_PERSON_ID INTEGER ) CREATE TABLE JOB ...
<p>I'm not following.</p> <p>You cannot delete <code>JOB</code> rows which have <code>JOB_PERSON</code> rows (even one) because of your FK contraints. Thus there is no way to delete <code>JOB</code> rows based on <code>PERSON</code> rows.</p> <p><code>JOB_PERSON</code> rows have to be deleted before either a <code>J...
<p>This will delete from your table JOB entries which have no entry in the table JOB_PERSON (Orpheans).</p> <pre><code>DELETE FROM JOB WHERE JOB_ID NOT IN ( SELECT JOB_ID FROM JOB_PERSON ) </code></pre> <p>You can't delete rows which are linked by a foreign on an other table...</p>
34,257
<p>I tried to precompile my ASP.NET MVC application and deploy it to an IIS6 box (with wildcard mapping), however I am getting an error with rendering partial views (user controls). Its working fine on my dev machine before precompiling.</p> <p>The error is:</p> <blockquote> <p>Server Error in '/' Application.<br ...
<p>You can precompile an MVC app by placing this in the post-build actions in project properties:</p> <pre><code>C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler -p "$(ProjectDir)." -v /$(ProjectName) </code></pre> <p>This takes a little longer than without it, however you get the added ability to detect...
<p>Although you can precompile an MVC site the ascx and aspx view files are not in the compiled dll only the .cs files are. You will still need to deploy the .aspx and .ascx view files.</p> <p>Hope this helps</p>
43,613
<p>I've been reading a lot about closures and I think I understand them, but without clouding the picture for myself and others, I am hoping someone can explain closures as succinctly and clearly as possible. I'm looking for a simple explanation that might help me understand where and why I would want to use them.</p>...
<p><a href="http://mrevelle.blogspot.com/2006/10/closure-on-closures.html" rel="noreferrer">Closure on closures</a></p> <blockquote> <p>Objects are data with methods attached, closures are functions with data attached.</p> </blockquote> <pre><code>def make_counter(): i = 0 def counter(): # counter() is ...
<p>The best explanation I ever saw of a closure was to explain the mechanism. It went something like this:</p> <p>Imagine your program stack as a degenerate tree where each node has only one child and the single leaf node is the context of your currently executing procedure.</p> <p>Now relax the constraint that each...
3,479
<p>I'm trying to figure out a method of connecting from C# code to a digital scale. The particular scale is an Ohaus SP202 digital scale which comes with a USB connection. I would like to read the weight measured on the scale programmatically. I don't have the scale yet, I'm just doing the research before hand.</p> <...
<p>USB Hardware communication popularly works one of three ways.</p> <ol> <li><p>Proprietary software talks to hardware via proprietary driver.</p></li> <li><p>Devices have a Serial emulation chip (e.g. <a href="http://www.ftdichip.com/FTProducts.htm#FT232R" rel="noreferrer">FTDI</a>) When you plug in the scale you ju...
<p>I don't know any details on this scale, but I've done some USB stuff.</p> <p>Its most likely using usb interrupt to transfer the data. All usb mice also use interrupt, so if you can figure out how to read the mouse signal (with using an HID api), then it should be exactly the same as the scale, except the data for...
43,100
<p>I want to escape a DOS filename so I can use it with sed. I have a DOS batch file something like this:</p> <pre><code>set FILENAME=%~f1 sed 's/Some Pattern/%FILENAME%/' inputfile </code></pre> <p>(Note: <code>%~f1</code> - expands <code>%1</code> to a Fully qualified path name - <code>C:\utils\MyFile.txt</code>)<...
<p>This will work. It's messy because in BAT files you can't use set var=`cmd` like you can in unix. The fact that echo doesn't understand quotes is also messy, and could lead to trouble if <code>Some Pattern</code> contains shell meta characters.</p> <pre><code>set FILENAME=%~f1 echo s/Some Pattern/%FILENAME%/ | sed...
<p>@Alexandru &amp; Jeremy, Thanks for your help. You both get upvotes</p> <p>@Jeremy</p> <p>Using your method I got the following error:</p> <blockquote> <p>sed: -e expression #1, char 8: unterminated `s' command</p> </blockquote> <p>If you can edit your answer to make it work I'd accept it. (pasting my soluti...
5,572
<p>I'd like to enable/disable some other controls based on how many items are in my <code>ListView</code> control. I can't find any event that would do this, either on the <code>ListView</code> itself or on the <code>ListViewItemCollection</code>. Maybe there's a way to generically watch any collection in C# for change...
<p>@Domenic</p> <p>Not too sure, Never quite got that far in the thought process. </p> <p>Another solution might be to extend ListView, and when adding and removing stuff, instead of calling .items.add, and items.remove, you call your other functions. It would still be possible to add and remove without events being...
<p>I can't find any events that you could use. Perhaps you could subclass ListViewItemCollection, and raise your own event when something is added, with code similar to this.</p> <pre><code>Public Class MyListViewItemCollection Inherits ListView.ListViewItemCollection Public Event ItemAdded(ByVal Item As Lis...
6,936
<p>I am familiar with using the <em>os.system</em> to run from the command line. However, I would like to be able to run a jar file from inside of a specific folder, eg. my 'test' folder. This is because my jar (located in my 'test' folder) requires a file inside of my 'test' folder. So, how would I write a function in...
<p>Here is a small script to get you started. There are ways to make it "better", but not knowing the full scope of what you are trying to accomplish this should be sufficient.</p> <pre><code>import os if __name__ == "__main__": startingDir = os.getcwd() # save our current directory testDir = "\\test" # note th...
<p>In general: Use os.chdir to change the directory of the parent process, then os.system to run the jar file. If you need to keep Python's working directory stable, you need to chdir back to original working directory - you need to record that with os.getcwd().</p> <p>On Unix: Create a child process with os.fork expl...
38,327
<p>What are the API calls to copy a file that is currently locked. I'm hoping to be able to use .Net, but Win32 calls would be fine as well. </p> <p>Please feel free to chime in about the same functionality on Unix, or any other OS.</p>
<p>You can use the VSS (Volume Shadow Copy Service, not Visual SourceSafe) API for this purpose. While powerful, this isn't exactly an easy-to-use API: the <a href="http://msdn.microsoft.com/en-us/library/aa384589.aspx" rel="noreferrer">Overview of Processing a Backup Under VSS</a> should give you an idea what's involv...
<p>Depending upon what exactly has locked your file, you can either do System.IO.File.Copy(), or create a System.IO.BinaryReader and a System.IO.BinaryWriter and manually create a copy of the file by reading chunks of the locked file and writing them to a new file. I have seen situations where one method was possible ...
32,384
<p>Is there a way to use constants in <strong>JavaScript</strong>?</p> <p>If not, what's the common practice for specifying variables that are used as constants?</p>
<p>Since <a href="https://www.ecma-international.org/ecma-262/6.0/" rel="noreferrer">ES2015</a>, JavaScript has a notion of <a href="https://www.ecma-international.org/ecma-262/6.0/#sec-let-and-const-declarations" rel="noreferrer"><code>const</code></a>:</p> <pre><code>const MY_CONSTANT = "some-value"; </code></pre> ...
<p>Checkout <a href="https://www.npmjs.com/package/constjs" rel="nofollow">https://www.npmjs.com/package/constjs</a>, which provides three functions to create enum, string const and bitmap. The returned result is either <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fre...
15,833
<p>I have a very simple SOAP web service that I need to consume from a Java client. What is the easiest way to accomplish this without using any third party libraries? A requirement is that the host and port is read from the web.xml before every call to the ws.</p>
<p>Depending on which version of JAVA you're using, some of the JAX-WS is built into it. JDK 6 has Java's JAX-WS standard implementation and you could just use it. </p> <p>See the following:</p> <ul> <li><p><a href="http://weblogs.java.net/blog/ramapulavarthi/archive/2008/01/jaxws_21_and_ja.html" rel="noreferrer">JAX...
<p>Without using any third party libraries? Get to know the SOAP standard really well and learn to love SAX.</p> <p>If you can't love SAX, then lax your no-third-party-libs requirement and use StAX (with woodstox) instead.</p> <p>This approach might be the "easiest" (considering the no-third-party-libs requirement) b...
37,227
<p>Is there a "win64" identifier in Qmake project files? <a href="http://doc.trolltech.com/4.4/qmake-advanced-usage.html" rel="noreferrer">Qt Qmake advanced</a> documentation does not mention other than unix / macx / win32.</p> <p>So far I've tried using:</p> <pre><code>win32:message("using win32") win64:message("usi...
<p>I do it like this</p> <pre><code>win32 { ## Windows common build here !contains(QMAKE_TARGET.arch, x86_64) { message("x86 build") ## Windows x86 (32bit) specific build here } else { message("x86_64 build") ## Windows x64 (64bit) specific build here } } </code></...
<p>No, but you can create and use a new mkspec, I think qmake also defines a platform identifier named after the current mkspec. Why do you need to test for 64 bit?</p> <p>Reed</p>
46,505
<p>Since some time, my Delphi debugger became much slower than I was used to before.</p> <p>I noticed this in both Delphi 2007 and 2009, so it seems it's something outside of Delphi itself...</p> <p>What causes this behaviour, and how can I prevent this?</p>
<p>After weeks of searching for an answer, I found this Microsoft knowledge base article fixes my problem : <a href="http://support.microsoft.com/kb/321410/nl" rel="nofollow noreferrer">http://support.microsoft.com/kb/321410/nl</a></p> <p>The point is, I installed Microsoft Script Editor a while back to do some server...
<p>This happened to me too, it started after I installed XP Service pack 3 and stopped after we switched from a Windows Workgroup to a Domain. </p> <p>While I was lingering in slowness I found that if I started my program, them attached to the process I could debug at normal speeds. </p> <p>I also read that sometime...
24,963
<p>Here is a simple overview of my directory layout for my views:</p> <p>Project</p> <ul> <li>Page 1</li> <li>Page 2</li> <li>RSS</li> </ul> <p>Issues</p> <ul> <li>Page 1</li> <li>Page 2</li> <li>RSS</li> </ul> <p>I am using forms authentication to deny access to all unauthenticated users, that works fine. However...
<p>Forget about the &lt;location>&lt;allow />&lt;deny /> stuff... sounds like you need to use the [Authorize] attribute on your actions.</p> <p>Check out these pages for more info: <a href="http://www.asp.net/learn/mvc/tutorial-17-cs.aspx" rel="nofollow noreferrer">http://www.asp.net/learn/mvc/tutorial-17-cs.aspx</a> ...
<p>This might not be working as intended. </p> <p>It seems that, in my case at least, you still need the authentication cookie in order to see the page. You can be logged out and view it, so long as you have the cookie.</p> <p>That is no good to me, I need the page to be completely public, as it is an RSS feed. </p>
44,301
<p>I often run into code that has to perform lots of checks and ends up being indented at least five or six levels before really doing anything. I am wondering what alternatives exist.</p> <p>Below I've posted an example of what I'm talking about (which isn't actual production code, just something I came up with off ...
<p>See <a href="http://www.codinghorror.com/blog/archives/000486.html" rel="nofollow noreferrer">Flattening Arrow Code</a> for help.</p> <blockquote> <ol> <li>Replace conditions with guard clauses.</li> <li>Decompose conditional blocks into seperate functions.</li> <li>Convert negative checks into positi...
<p>if it's just a readability issue you could make it clearer by moving the nesting to another method. Additionally convert to guard style if you like.</p> <pre><code>public String myFunc(SomeClass input) { Object output = null; if (inputIsValid(input)) { //now actually do stuff! message = re...
46,990
<p>I am trying to write a web-app to manage references for my PhD thesis.</p> <p>I used to manage this information inside a personal Confluence (fantastic tool! - <a href="http://www.atlassian.com/software/confluence/" rel="nofollow noreferrer">http://www.atlassian.com/software/confluence/</a>) instance however I'm fe...
<p>Try using the <a href="http://livedemo.exadel.com/richfaces-demo/richfaces/paint2D.jsf?c=paint2d&amp;tab=usage" rel="nofollow noreferrer">RichFaces Paint 2D</a> tag</p> <p>It exposes the <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Graphics2D.html" rel="nofollow noreferrer">Graphics2D</a> package to th...
<p>Have you considered <a href="http://www.mendeley.com/" rel="nofollow noreferrer">Mendeley</a> ? It will try to parse and extract bibliographic information from your pdfs.</p>
9,636
<p>I have a command line Ruby app I'm developing and I want to allow a user of it to provide code that will run as a filter on part of the process. Basically, the application does this:</p> <ol> <li>read in some data</li> <li>If a filter is specified, use it to filter data</li> <li>process the data</li> </ol> <p>I w...
<p>I'd just use a combination of the command line, and convention.</p> <blockquote> <p>If a filter is specified, use it to filter data</p> </blockquote> <p>I'm assuming you'd specify a filter on the command line? So you'd invoke the application like this?</p> <pre><code>ruby dataprocessor.rb custom_filter </code><...
<p>Looks like a job for a <a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="nofollow noreferrer">Strategy Pattern</a>, and since ruby has <a href="http://weblog.raganwald.com/2007/01/closures-and-higher-order-functions.html" rel="nofollow noreferrer">functions as first-class objects</a>, you might pass the f...
31,316
<p>I need to increment a String in java from "aaaaaaaa" to "aaaaaab" to "aaaaaac" up through the alphabet, then eventually to "aaaaaaba" to "aaaaaabb" etc. etc.</p> <p>Is there a trick for this?</p>
<p>You're basically implementing a <a href="http://en.wikipedia.org/wiki/Base_26" rel="noreferrer">Base 26 number system</a> with leading "zeroes" ("a").</p> <p>You do it the same way you convert a int to a base-2 or base-10 String, but instead of using 2 or 10, you use 26 and instead of '0' as your base, you use 'a'....
<p>It's not much of a "trick", but this works for 4-char strings. Obviously it gets uglier for longer strings, but the idea is the same.</p> <pre><code>char array[] = new char[4]; for (char c0 = 'a'; c0 &lt;= 'z'; c0++) { array[0] = c0; for (char c1 = 'a'; c1 &lt;= 'z'; c1++) { array[1] = c1; for (char c2...
44,458
<p>Back in VB6, I wrote a few functions that would let me code without having to care about the difference between null and '' for strings, null and 0 for numbers, etc. Nothing kills my productivity more when coding than having to add special case code for dealing with data that might cause some irrelevant error; 9999...
<p>There are scads of conversion functions built-in. But... i'm not sure any of them do exactly what you want. Generally, .NET methods err on the side of caution when passed invalid input, and throw an exception. </p> <p>Fortunately, you can easily write a utility method to convert a string representation of a numeric...
<p>There is a class called Convert in the .NET library. It has functions that allow you to convert to whatever you need from any base type and a few of the common classes (like DateTime.)</p> <p>It basically works like Convert.ToInt32(val);</p> <p>EDIT: I really need to learn to read all the words. Didn't catch the...
20,590
<p>Is it possible to get UI text from an external application in C#. </p> <p>In particular, is there a way to read Unicode text from a label (I assume it's a normal Windows label control) from an external Win32 app that was written by a 3rd party? The text is visible, but not selectable by mouse in the UI.</p> <p>I a...
<p>You could do it if that unicode text is actually a window with a caption by sending a <a href="http://msdn.microsoft.com/en-us/library/ms632627.aspx" rel="nofollow noreferrer">WM_GETTEXT</a> message. </p> <pre><code>[DllImport("user32.dll")] public static extern int SendMessage (IntPtr hWnd, int msg, int Param, Sys...
<p>didn't see the values for wm_gettext or wm_gettextlength in that article, so just in case..</p> <pre><code>const int WM_GETTEXT = 0x0D; const int WM_GETTEXTLENGTH = 0x0E; </code></pre>
3,919
<p>I have two tables, one stores the products and quantity we have bought, the other stores the sells. The current stock is therefore the sum of all the quantity columns in the bought table minus the number of rows in the sells table. How can this be expressed in MySQL. Remember that there are many different products.<...
<p>Try this</p> <pre><code> SELECT inv_t.product_id, inventory_total-nvl(sales_total,0) FROM (SELECT product_id, sum(quantity) as inventory_total FROM inventory GROUP BY product_id) inv_t LEFT OUTER JOIN (SELECT product_id, count(*) AS sales_total FROM sales GROUP BY product_id) sale_t ON (inv_t.p...
<pre><code>SELECT product AS prd, SUM(quantity) - IFNULL((SELECT COUNT(*) FROM sells WHERE product = prd GROUP BY product), 0) AS stock FROM bought GROUP BY product; </code></pre> <p>This one also works when quantity sold is 0.</p>
30,098
<p>Trying to honor a feature request from our customers, I'd like that my application, when Internet is available, check on our website if a new version is available.</p> <p>The problem is that I have no idea about what have to be done on the server side.</p> <p>I can imagine that my application (developped in C++ us...
<p>I would absolutely recommend to just do a plain HTTP request to your website. Everything else is bound to fail.</p> <p>I'd make a HTTP GET request to a certain page on your site containing the version of the local application.</p> <p>like</p> <pre><code>http://www.example.com/update?version=1.2.4 </code></pre> <...
<p>The simplest way to make this happen is to fire an HTTP request using a library like <a href="http://curl.haxx.se/libcurl/" rel="nofollow noreferrer">libcurl</a> and make it download an ini or xml file which contains the online version and where a new version would be available online.</p> <p>After parsing the xml ...
8,031
<p>I have an ASP.Net 3.5 platform and windows 2003 server with all the updates. </p> <p>There is a limit with .Net that it cannot handle more than <a href="http://forums.iis.net/p/1105360/1689855.aspx" rel="noreferrer">260 characters</a>. Moreover if you look it up on web, you will find that IE 6 fails to work if it i...
<p>A Url is path + querystring, and the linked article only talks about limiting the path. Therefore, if you're using asp.net, don't exceed a path of 260 characters. Less than 260 will always work, and asp.net has no troubles with long querystrings.</p> <pre><code>http://somewhere.com/directory/filename.aspx?id=1234 ...
<p>More information is needed but for normal situations I would say try to keep it under 150 for sure. If for nothing else than pure ascetics, I hate when someone sends me a GI-NORMOUS link... </p> <p>Are you passing values through the query string? I assume that is why you asked, correct?</p>
21,615
<p>Hey so theres a product we have been prototyping. We cant do FDM. The item has a ball valve. and the ball ~ 1.6-1.9mm I cant seem to prototype it. I have tried SLS, SLA, Polyjet. Anybody knows what could be wrong, or what should be the dimension i should be using? I thought I would post this at engineering secti...
<p>Hey why to make it soooo sophisticated and poor? Air valve cannot be designed with 2 stiff elements - it will never work.</p> <p>Make the air your friend but not the enemy. Use old good rubber (silicone) "flake" instead. Especially when you have such small design.</p> <p>Take a look on the picture.</p> <p><a href...
<p>As mentioned above in the comments, this really isn't a good application of 3D Printing. At least, not with expectation that it functions. I'd suggest using 3D printing to verify other dimensions and having the part machined traditionally. That ball and "seal" needs to be precision ground or honed to fit in order to...
268
<p>Here is the situation. This small company I'm working with wants to have a redundant internet access. They run bunch of services from their office - a website, POP+SMTP server and use VPN for accessing network shares from home. They have 2 independent internet connections from 2 ISP's (one is a local cable provider,...
<p>Last time I did it, I had my own ASN and spoke BGP to both ISPs announcing my own /24 (which you can get from either ISP, or maybe ARIN). You could go down this route, but its a fair bit of setup. And a random Cable/DSL ISP probably won't set this up with you. This does eliminate all the points of failure and makes ...
<p>you can setup a route-map with default-nexthop.</p> <p>This will take care of outgoing traffic and not incoming redundancy which would require an AS number and BGP announcements of a block that is at least a /24 as ISPs will not announce anything smaller than a /24 block. </p>
45,640
<p>My event logs on my production front end servers are getting filled with error messages:</p> <p>"Failed to determine definition for Feature with ID"</p> <p>Now, I've found the offending feature on one of the development servers - it is an InfoPath form with some code behind. But, it is nowhere to be found on the ...
<p>I'm not sure but I think copying that feature definition to the production's 12/TEMPLATES/FEATURES and then uninstalling it may help. </p> <p>But it is not clear from this error message "Failed to determine definition for Feature with ID" what part of your production system is tied to the feature and what action is...
<p>Try this: <a href="http://featureadmin.codeplex.com/" rel="nofollow noreferrer">SharePoint Feature Administration and Clean Up Tool</a> </p> <blockquote> <p>Find faulty FeatureDefinitions and cleanly uninstall them. Find Feature remainders in Sites, SiteCollections, WebApps and in the Farm, from e.g. forcefull...
30,287
<p>I need to encrypt and decrypt a querystring in ASP.NET. </p> <p>The querystring might look something like this:</p> <blockquote> <p><a href="http://www.mysite.com/report.aspx?id=12345&amp;year=2008" rel="noreferrer">http://www.mysite.com/report.aspx?id=12345&amp;year=2008</a></p> </blockquote> <p>How do I go ab...
<p>Here is a way to do it in VB From: <a href="http://www.devcity.net/Articles/47/1/encrypt_querystring.aspx" rel="noreferrer">http://www.devcity.net/Articles/47/1/encrypt_querystring.aspx</a></p> <p><strong>Wrapper for the encryption code:</strong> Pass your querystring parameters into this, and change the key!!!</p>...
<p>Why are you trying to encrypt your query string? If the data is sensitive, you should be using SSL. If you are worried about someone looking over the user's shoulder, use form POST instead of GET.</p> <p>I think it is pretty likely that there is a better solution for your fundamental problem than encrypting the que...
29,793
<p>I have the following SQL query:</p> <pre><code>select expr1, operator, expr2, count(*) as c from log_keyword_fulltext group by expr1, operator, expr2 order by c desc limit 2000; </code></pre> <p>Problem: The <code>count(*)</code> as part of my order by is killing my application, probably because it don't use in...
<p>You are running a query which needs to scan the whole of a table, this does not scale. There is no WHERE clause, so it absolutely needs to scan the whole thing.</p> <p>Consider maintaining some summary table(s) instead of doing this query often.</p>
<p>Trying to count and sort by it is going to be a killer. I would suggest trying to make a temporary table with the counts, and then do a select...order by on that.</p> <p>Not sure if this works in MySQL, but in PostreSQL or Oracle, that would be</p> <pre><code>create foo as select expr1, operator, expr2, count...
46,865
<p>All the docs for SQLAlchemy give <code>INSERT</code> and <code>UPDATE</code> examples using the local table instance (e.g. <code>tablename.update()</code>... )</p> <p>Doing this seems difficult with the declarative syntax, I need to reference <code>Base.metadata.tables["tablename"]</code> to get the table reference...
<p>well it works for me:</p> <pre><code>class Users(Base): __tablename__ = 'users' __table_args__ = {'autoload':True} users = Users() print users.__table__.select() </code></pre> <p>...SELECT users.......</p>
<p>There may be some confusion between <strong>table</strong> (the object) and <strong>tablename</strong> (the name of the table, a string). Using the <strong>table</strong> class attribute works fine for me.</p>
10,150
<p>I'm looking for a database of commonly installed Windows software. At minimum I need the name of the software and the executable name, but it'd also be nice to have the publisher and the common installation path, etc. Basically, I'd like to be able to query it to find all the software by Adobe and the associated exe...
<p>Your best bet would be to <a href="http://www.developer.com/net/asp/article.php/3079381" rel="noreferrer">query</a> amazon.com, since they sell lots of software and provide public interfaces to access their database.</p>
<p>You can do some <strong>screen scraping</strong> with some website that contain <strong>list of software</strong> and build yourself a database of all software and publisher.</p> <p>Here is some website that contain some list of software:</p> <ul> <li><a href="http://www.digital-digest.com/software/index.php" rel=...
27,534
<p>I plan to use PyInstaller to create a stand-alone python executable. PythonInstaller comes with built-in support for UPX and uses it to compress the executable but they are still really huge (about 2,7 mb).</p> <p>Is there any way to create even smaller Python executables? For example using a shrinked python.dll or...
<p>If you recompile pythonxy.dll, you can omit modules that you don't need. Going by size, stripping off the unicode database and the CJK codes creates the largest code reduction. This, of course, assumes that you don't need these. Remove the modules from the pythoncore project, and also remove them from PC/config.c</...
<p>You can't go too low in size, because you obviously need to bundle the Python interpreter in, and only that takes a considerable amount of space.</p> <p>I had the same concerns once, and there are two approaches:</p> <ol> <li>Install Python on the computers you want to run on and only distribute the scripts</li> <...
31,764
<p>I've written an Apache module in C. Under certain conditions, I can get it to segfault, but I have no idea as to why. At this point, it could be my code, it could be the way I'm compiling the program, or it could be a bug in the OS library (the segfault happens during a call to dlopen()).</p> <p>I've tried running ...
<p>Unfortunately the GNU tools are not the best, and my experience is that the dynamic linker muddies the waters enormously. If you can get Apache to link statically with your module that will enable gdb especially to perform more reliably. I don't know how easy that is; a lot depends on the Apache build system.</p> ...
<p>I had a look at the valgrind documentation and by default it doesn't check child processes. It wouldn't surprise me at all if <strong>Apache could run your module in a child thread</strong>. Please try</p> <pre><code>valgrind --trace-children=yes .... </code></pre>
47,709
<p>I have a string which holds a decimal value in it and I need to convert that string into a floating point variable. So an example of the string I have is "5.45" and I want a floating point equivalent so I can add .1 to it. I have searched around the internet, but I only see how to convert a string to an integer.</p>...
<p>You don't need to convert it at all:</p> <pre><code>% perl -e 'print "5.45" + 0.1;' 5.55 </code></pre>
<p>Perl is weakly typed and context based. Many scalars can be treated both as strings and numbers, depending on the operators you use. <code>$a = 7*6; $b = 7x6; print "$a $b\n";</code> <br>You get <code>42 777777</code>.</p> <p>There is a subtle difference, however. When you read numeric data from a text file into a ...
36,783
<p>How and why do 7- and 35-pass erases work? Shouldn't a simple rewrite with all zeroes be enough?</p>
<p>I'd never heard of the 35-part erase: <a href="http://en.wikipedia.org/wiki/Gutmann_method" rel="noreferrer">http://en.wikipedia.org/wiki/Gutmann_method</a></p> <blockquote> <p>The Gutmann method is an algorithm for securely erasing the contents of computer hard drives, such as files. Devised by Peter Gutma...
<p>Regarding the second part of the question, some of the answers here actually contradict real research on that exact atopic. According the the <a href="http://en.wikipedia.org/wiki/Data_erasure#Number_of_overwrites_needed" rel="nofollow">Number of overwrites needed</a> of the <a href="http://en.wikipedia.org/wiki/Dat...
34,918
<p>I'm creating a installer for a c# windows project using VS 2008. I'm trying to write a custom action that copies a settings file from the source directory of the MSI file stored on a file server (e.g. \server\fileshare\myappinstaller\mysetting.xml) to the target directory on the computer on which my application is b...
<p>I have solved this by adding </p> <blockquote> <p>/InstallerPath="[OriginalDatabase]"</p> </blockquote> <p>to the CustomActionData of the Custom Action (in the Tab Custom Actions of the Setup Project) and reading the value with this code in the Custom Action:</p> <pre><code> Public Overrides Sub Commit(ByVal...
<p>Normally custom actions in WindowsInstaller use something from the tables of the msi to put something into any table of the msi.</p> <p>Additionally the WindowsInstaller-Team declines any managed extensions for the installers, reasons for that are found everywhere on the net.</p> <p>But, I did some time ago figure...
48,059
<p>Does anyone know of a way to monitor table record changes in a SQL Server (2005 or 2008) database from a .Net application? It needs to be able to support multiple clients at a time. Each client will "subscribe" when it starts, and "unsubscribe" when it exits. Multiple users could be accessing the system at once a...
<p>To monitor for changes to a SQL table or record in SQL 2005+ you can utilize the SqlDependency class.</p> <p>It is targeted for use in ASP.NET or a middle-tier service where a single server is managing active subscriptions against a database - not multiple hundreds of clients managing subscriptions. Depending on t...
<p>I haven't personally used it, but it sounds like Notification Services is worth a look</p> <p><a href="http://www.microsoft.com/sqlserver/2005/en/us/notification-services.aspx" rel="nofollow noreferrer">More Here...</a></p>
44,453
<p>Can you round a .NET <code>TimeSpan</code> object?</p> <p>I have a <code>Timespan</code> value of: 00:00:00.6193789</p> <p>Is there a simple way to keep it a <code>TimeSpan</code> object but round it to something like<br> 00:00:00.62?</p>
<p>Sorry, guys, but <strong><em>both</em></strong> the question and the popular answer so far are wrong :-)</p> <p>The question is wrong because Tyndall asks for a way to <strong><em>round</em></strong> but shows an example of <strong><em>truncation</em></strong>.</p> <p>Will Dean's answer is wrong because it also ad...
<p>Yet another way to round milliseconds to the nearest second.</p> <pre><code>private const long TicksPer1000Milliseconds = 1000 * TimeSpan.TicksPerMillisecond; // Round milliseconds to nearest second // To round up, add the sub-second ticks required to reach the next second // To round down, subtract the sub-second...
43,966
<p>I have been pushing into the .NET framework in PowerShell, and I have hit something that I don't understand. This works fine:</p> <pre><code>$foo = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]" $foo.Add("FOO", "BAR") $foo Key ...
<p>In PowerShell 2.0 the new way to create a <code>Dictionary</code> is:</p> <pre><code>$object = New-Object 'system.collections.generic.dictionary[string,int]' </code></pre>
<p>There are some issues with Generics in PowerShell. Lee Holmes, a dev on the PowerShell team posted <a href="http://www.leeholmes.com/blog/CreatingGenericTypesInPowerShell.aspx" rel="nofollow noreferrer">this script</a> to create Generics.</p>
22,304
<p>I have a webpage (say www.example.com/a.asp) .. I am having an iframe in this page which loads a page from a different website (www.example.net/b.asp)... This b.asp asks few questions to the user and the results are posted to c.asp in my website (www.example.com/c.asp). This page (www.example.com/c.asp) gets loaded ...
<p>Views are typically expanded in place into subqueries, unless you explicitly mark the views as persisted by dropping a clustered index on them.</p>
<p>This is an 'It depends' question. A view might help to make the code more maintainable but complex selection predicates might confuse the optimiser.</p> <p>Another option is a stored procedure that returns a record set. If you reuse a subquery several times you may get some mileage from splitting up the query, se...
21,978
<pre><code>some_var = foo() another_var = bar() </code></pre> <p>or</p> <pre><code>some_var = foo() another_var = bar() </code></pre> <p>Including changing the whitespace as lines are added or removed to keep them lined up. Does this really look good? Is it worth the mucking up of the diff?</p>
<p>From my time as VCS admin, darn few stylistic issues are worth mucking up the diff. We had a developer change names with his sex change procedure, and her new first name didn't have the same initial. She then changed her former initials to her new ones whenever she worked on a program, and that caused me a lot of ...
<p>No, unless there is some vertical relationship between the variables, such as:</p> <pre><code>some_var[ 1] = "foo"; some_var[100] = "bar"; </code></pre> <p>But the cases are very rare that I do this, especially when I only have a few variables. This is a bit more common in SQL, where I might have the parameter n...
36,277
<p>Is there any way to define what the "Open Resource" dialog in Eclipse should show?</p> <p>If you work with svn you don't want the *.svn files to show up. (I know there is a fix out for this one but does there exist a more general one?)</p>
<p>At the top-right corner of the "Open Resource" there is a small blue arrow. Click it and "Select Working Set". Create a new working set as required to include what you need</p>
<p>You could mark the files as 'derived', though depending on their directory structure it could be time-consuming. See my answer to <a href="https://stackoverflow.com/q/2632419/292728">this question</a>.</p>
28,869
<p>I am trying to make a view slide from top to bottom. This is not a big deal, I used <code>CABasicAnimation</code> for this. The problem is when I want to remove the view. I use this animation.</p> <pre><code>CABasicAnimation *animation; animation = [CABasicAnimation animationWithKeyPath:@"position"]; [animation set...
<p>Might want to set these properties. They cause the presentation to be preserved at the end of the animation.</p> <p><code>animation.fillMode = kCAFillModeForwards;<br> animation.removedOnCompletion = NO;</code></p> <p>Then the "animationDidStop:" method can be used to remove the view at the end of the animation:</...
<p>Can you set the view's hidden property to YES?</p> <p>I think it would be:</p> <pre><code>self.view.hidden = YES; </code></pre> <p>But it might be:</p> <pre><code>[self.view setHidden:YES]; </code></pre> <p>I turns out I am pretty lame at figuring out the proper way to access properties of properties.</p>
28,018
<p>Anyone can read the GoF book to learn what design patterns are and how to use them, but what is the process for figuring out when a design pattern solves a problem? Does the knowledge of the pattern drive the design, or is there a way to figure out how a pattern can be used to change a design?</p> <p>In other words...
<p>Design patterns are supposed to provide a structure <em>in which</em> problems can be solved. When solving a real problem, you have to consider <em>many</em> tiny variations of a solution to that problem to see whether any fits a design pattern. In particular, you will probably need to generalise your problem, or ...
<p>A design pattern is a <strong><em>generic description</em></strong> on how to solve a <strong><em>common problem</em></strong>. There're 2 things we should pay attention to:</p> <p>First, it is a <strong><em>Generic description</em></strong>; it's not the concrete solution, and it's not a complete recipe either, it...
11,083
<p>I have multiple controller actions that takes an id</p> <pre><code>public ActionResult Get(int? id) { ... } public ActionResult Delete(int id) { ... } public JsonResult GetJson(int? id) { ... } </code></pre> <p>I'm thinking its best practice to use a ModelBinder (SomeObjectFromIDModelBinder) on each action, so t...
<p>We have done something like this. And it works for very simple pages. But as soon as you would like to include some client side javascript and similar, you are doomed.</p> <p>The generated output is hidden in the XSLT stylesheets and it is very hard to read, maintain and fix bugs. </p> <p>Testing can be done, but ...
<p>Two cons.</p> <ol> <li><p>Data manipulation with C# or VB.net becomes harder because you don't have classes with properties (code intellisense) but xml-documents. </p></li> <li><p>There are built in asp.net controls for data entry validation (both client side and server side). You can't use them if you use XSLT to ...
49,902
<p>We have a decent sized object-oriented application. Whenever an object in the app is changed, the object changes are saved back to the DB. However, this has become less than ideal.</p> <p>Currently, transactions are stored as a transaction and a set of transactionLI's.</p> <p>The transaction table has fields for...
<p>We have taken the following approach:-</p> <ol> <li><p>All objects are serialised (using the standard XMLSeriliser) but we have decorated our classes with serialisation attributes so that the resultant XML is much smaller (storing elements as attributes and dropping vowels on field names for example). This could be...
<p>I've never found a great end all solution for this type of problem. Some things you can try is if your DB supports partioning (or even if it doesn't you can implement the same concept your self), but partion this log table by object type and then you can further partion by date/time or by your object ID (if your ID ...
33,760
<p>How far do you go with <code>const</code>? Do you just make functions <code>const</code> when necessary or do you go the whole hog and use it everywhere? For example, imagine a simple mutator that takes a single boolean parameter:</p> <pre><code>void SetValue(const bool b) { my_val_ = b; } </code></pre> <p>Is th...
<p>The reason is that <code>const</code> for the parameter only applies locally within the function, since it is working on a copy of the data. This means the function signature is really the same anyways. It's probably bad style to do this a lot though.</p> <p>I personally tend to not use <code>const</code> except for...
<p>There's really no reason to make a value-parameter "const" as the function can only modify a copy of the variable anyway.</p> <p>The reason to use "const" is if you're passing something bigger (e.g. a struct with lots of members) by reference, in which case it ensures that the function can't modify it; or rather, t...
14,282
<p>Let's say there's a.gz, and b.gz.</p> <p>$ gzip_merge a.gz b.gz -output c.gz</p> <p>I'd like to have this program. Of course,</p> <p>$ cat a.gz b.gz > c.gz</p> <p>doesn't work. Because the final DEFLATE block of a.gz has BFINAL, and the GZIP header of b.gz. (Refer to RFC1951, RFC1952) But if you unset BFINAL, th...
<blockquote> <p>Of course, cat a.gz b.gz > c.gz doesn't work.</p> </blockquote> <p>Actually, it works just fine. I just tested it. It's even documented (sort of) in the gzip man page.</p> <pre><code> Multiple compressed files can be concatenated. In this case, gunzip will extract all members at once. For...
<p>You could also:</p> <pre><code>zcat a.gz b.gz &gt; c.txt &amp;&amp; gzip c.txt </code></pre> <p>as long as your Linux/Unix distribution has zcat built in, which most of them do (and you could install it for the ones that do not.)</p> <p>Alternatively:</p> <pre><code>zcat a.gz b.gz | gzip -c &gt; c.txt.gz </code>...
34,542
<p>With the following piece of code:</p> <pre><code>typedef struct { char fileName[ 1024]; time_t deleteTime; } file_item_t; .... .... setEntry(char *fileName) { file_item_t file; memset( &amp;file, 0x00, sizeof( file_item_t )); memcpy( file.fileName, fileName, size...
<p>You already hit the nail on the head:</p> <p>In your memcpy you're reading past the length of filename. </p> <p>Also dirty that will often work if the memory behind the filename is readable. In most cases it is, but if you for example pass a string-literal as an argument, and the linker puts the string into the la...
<p>Are you sure the string pointed to by <code>fileName</code> is really 1024 bytes in length? It somehow feels to me you should strcpy instead of memcpy.</p> <p>If fileName is shorter, the memcpy copies the bytes behind the real string data, and will probably cause an access violation reading that memory.</p>
23,152
<p>I'm making a Stored Procedure that basically concatenates a long string with data from many records.</p> <p>I want to do:</p> <pre><code>set @output = @output + 'aaa' + LINEBREAK </code></pre> <p>How do I specify that line break?</p>
<pre><code>DECLARE @LINEBREAK AS varchar(2) SET @LINEBREAK = CHAR(13) + CHAR(10) </code></pre>
<p>Try this:</p> <pre><code>set @output = @output + 'aaa' + char(13) </code></pre>
21,898
<p>Nokia has stopped offering its Developer's Suite, relying on other IDEs, including Eclipse. Meanwhile, Nokia changed its own development tools again and EclipseMe has also changed. This leaves most documentation irrelevant. </p> <p>I want to know what does it take to make a simple Hello-World?</p> <p>(I already fo...
<p>Here's what's needed to make a simple hello world -</p> <ol> <li>Get <a href="http://www.eclipse.org/downloads/" rel="nofollow noreferrer">Eclipse</a> IDE for Java. I used Ganymede. Set it up.</li> <li>Get Sun's <a href="http://java.sun.com/products/sjwtoolkit/download.html" rel="nofollow noreferrer">Wireless Toolk...
<p>The most annoying issue with EclipseME for me was the "broken" debugger, which just wouldn't start. This is covered in docs, but it took me about an hour to find this tip when I first installed EclipseME, and another hour when I returned to JavaME development a year later, so I decided to share this piece of knowled...
8,792
<p>Our build is dog slow. It uses nested gnu makefiles on linux. It creates three builds for three different targets from the same source tree. It uses symlinks to point to each of the three parallel directory trees in turn. We can do partial builds by using make inside subdirectories, which saves time, but if our work...
<p>Considerations for speeding up your build:</p> <p>Builds tend to be I/O bound, so distribute the I/O across multiple drives/controllers or machines. For example, put the source on one physical drive and put the target (the build output) on a different physical drive, and separate both of those drives from the phys...
<p>We use icecream. Not to kill time while it builds, but to speed up the build process. It's a distributed compiling environnment that uses the spare CPU time of all the PCs in the office. Our setup is quite complex as we have a cross-compiling environment, but it could be much simpler if you aren't cross-compiling...
41,150
<p>How to decide whether to use threads or create separate process altogether in your application to achieve parallelism.</p>
<p>Threads are more light weight, and for the making several "workers" just to utilize all availabe CPUs or cores, you're better of with threads.</p> <p>When you need the workers to be better isolated and more robust, like with most servers, go with sockets. When one thread crashes badly, it usually takes down the ent...
<p>In Windows, processes are heavier to create then threads. So if you have several smaller tasks a thread or thread pool would be better. Or use a process pool to recycle the processes. Also sharing state between processes is more work then sharing state between threads. But then again: Threads could destabilize a com...
8,842
<p>I am trying to fill a form in a php application from a C# client (Outlook addin). I used Fiddler to see the original request from within the php application and the form is transmitted as a multipart/form. Unfortunately .Net does not come with native support for this type of forms (WebClient has only a method for up...
<p>This is cut and pasted from some sample code I wrote, hopefully it should give the basics. It only supports File data and form-data at the moment.</p> <pre><code>public class PostData { private List&lt;PostDataParam&gt; m_Params; public List&lt;PostDataParam&gt; Params { get { return m_Params;...
<p>I needed to simulate a browser login to a website to get a login cookie, and the login form was multipart/form-data.</p> <p>I took some clues from the other answers here, and then tried to get my own scenario working. It took a bit of frustrating trial and error before it worked right, but here is the code:</p> <p...
27,061
<p>I am developing a forms app (not web) for Windows Mobile, using .NET CF 3.5. I need an HTML editor control. I'm looking for something along the lines of a simple FCKEditor, but for using in a forms app (EXE).</p> <p>Any suggestions?</p>
<p>Pocket IE (the web browser included with Windows Mobile) is about as powerful as Netscape 2... without the Javascript support. So using a browser-based HTML editor isn't going to work with it. Opera has most of the power of the desktop version (including DOM and Javascript support), but I'm not sure it has an enbedd...
<p>About all I have that I can suggest is <a href="http://notepad-plus.sourceforge.net/uk/site.htm" rel="nofollow noreferrer">Notepad++</a>. I use it for Web stuff, but it has support for, I believe, 30+ languages, and it's free, so you may be able to find what you're looking for there.</p>
15,213
<p>I've got a whole host of values stored in a .net 2.0 hashtable. What I would really like to find is a way to, essentially, do a SQL select statement on the table.</p> <p>Meaning, I'd like to get a list of keys whose associated values match a very simple text pattern (along the lines of "starts with a number".)</p...
<p>You could use a regex against every key in the hashtable. This is very dirty but it works:</p> <pre><code> static void Main(string[] args) { Hashtable myhashtable = new Hashtable(); myhashtable.Add("Teststring", "Hello"); myhashtable.Add("1TestString1", "World"); myhashtable....
<p>Using LINQ:</p> <pre><code>Dim myhashtable As New Hashtable myhashtable.Add("Teststring", "Hello") myhashtable.Add("1TestString1", "World") myhashtable.Add("2TestString2", "Test") For Each i As String In From Element In myhashtable.Cast(Of DictionaryEntry)() Let k = DirectCast(Element.Value, String) Wh...
43,105
<p>i have a list of products that are being displayed in particular order. store admin can reassign the display order, by moving the "hot" items to the top of the list. what's the best way of implementing the admin functionality <b>UI</b> [asp.net C#]? Products table has a [displayOrder(int)] filed which determines the...
<p>using AJAX you could implement a Reoder list control you can find more information here <a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ReorderList/ReorderList.aspx" rel="nofollow noreferrer">http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ReorderList/ReorderList.aspx</a></p> <p>Mauro</p> <p><a href...
<p>i'm implementing that using the 'Order' column/property where people input numbers like 10, 20, 30 (i have ascending ordering). i have a list of items with text boxes to input order, and an 'apply order' button that saves new values to the database and reorders/reloads items on the page with the new ordering applied...
7,439
<p>I need to be able to take a string like:</p> <pre><code>'''foo, bar, "one, two", three four''' </code></pre> <p>into:</p> <pre><code>['foo', 'bar', 'one, two', 'three four'] </code></pre> <p>I have an feeling (with hints from #python) that the solution is going to involve the shlex module.</p>
<p>The shlex module solution allows escaped quotes, one quote escape another, and all fancy stuff shell supports.</p> <pre><code>&gt;&gt;&gt; import shlex &gt;&gt;&gt; my_splitter = shlex.shlex('''foo, bar, "one, two", three four''', posix=True) &gt;&gt;&gt; my_splitter.whitespace += ',' &gt;&gt;&gt; my_splitter.white...
<p>If it doesn't need to be pretty, this might get you on your way:</p> <pre><code>def f(s, splitifeven): if splitifeven &amp; 1: return [s] return [x.strip() for x in s.split(",") if x.strip() != ''] ss = 'foo, bar, "one, two", three four' print sum([f(s, sie) for sie, s in enumerate(ss.split('"'))]...
14,375
<p>I'm trying to figure out if there's a reasonably efficient way to perform a lookup in a dictionary (or a hash, or a map, or whatever your favorite language calls it) where the keys are regular expressions and strings are looked up against the set of keys. For example (in Python syntax):</p> <pre><code>&gt;&gt;&gt;...
<p>What you want to do is very similar to what is supported by xrdb. They only support a fairly minimal notion of globbing however.</p> <p>Internally you can implement a larger family of regular languages than theirs by storing your regular expressions as a character trie. </p> <ul> <li>single characters just become ...
<p>The fundamental assumption is flawed, I think. you can't map hashes to regular expressions. </p>
32,498
<p>What's the difference between <code>Char.IsDigit()</code> and <code>Char.IsNumber()</code> in C#?</p>
<p><code>Char.IsDigit()</code> is a subset of <code>Char.IsNumber()</code>.</p> <p>Some of the characters that are 'numeric' but not digits include 0x00b2 and 0x00b3 which are superscripted 2 and 3 ('²' and '³') and the glyphs that are fractions such as '¼', '½', and '¾'.</p> <p>Note that there are quite a few charac...
<p>I found the answer:</p> <blockquote> <p>Char.IsNumber() determines if a Char is of any numeric Unicode category. This contrasts with IsDigit, which determines if a Char is a radix-10 digit.</p> <p>Valid numbers are members of the following categories in <a href="http://msdn.microsoft.com/en-us/li...
28,277
<p>I've created a .Net library at work that is used by all of our developers. The security part of it uses Microsoft AzMan for the security backend. In order to create a security (AzMan) ClientContext I have to pass it a token value (as a uint). This is all fine an dandy until I needed to make a COM wrapper for our com...
<p>This is a result of my search on the subject as I was curious about your question and this is where I would start myself. Sorry I am not a specialist on the subject but hope it can kick-start you!</p> <p>Seems <a href="http://en.wikipedia.org/wiki/Floorplan_(microelectronics)" rel="noreferrer">floorplan</a> optimiz...
<p>There seems to be a class on this at Carnegie Mellon</p> <p><a href="http://www.ece.cmu.edu/~ee760/" rel="nofollow noreferrer">VLSI CAD</a></p> <p>some of the lecture notes that looked more interesting than others:</p> <ul> <li><a href="http://www.ece.cmu.edu/~ee760/760assignments.html" rel="nofollow noreferrer">...
44,851
<p>I'd like to be able to track file read/writes of specific program invocations. No information about the actual transactions is required, just the file names involved.</p> <p>Is there a cross platform solution to this? <br /> What are various platform specific methods? <br /> On Linux I know there's strace/ptrace...
<p>The short answer is no. There are plenty of platform specific solutions which all probably have similar interfaces, but they aren't inherently cross platform since file systems tend to be platform specific.</p> <hr> <blockquote> <p>How do I do it well on each platform?</p> </blockquote> <p>Again, it will depend...
<p>On Windows you can use the command line tool <a href="http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx" rel="nofollow noreferrer" title="Handle">Handle</a> or the GUI version <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow noreferrer" title="Process Explorer">Proces...
4,122
<p>I have a quick question. How do I get the image generated by a JComponent.paint or paintComponent?</p> <p>I have a JComponent which I use as a 'workspace' and where I have overwritten the paintComponent method to my own. The thing is that my workspace JComponent also has children which has their own paintComponent ...
<p>If you call getImage too early, your component will not have been displayed yet and will still have a 0 width and height. Have you made sure you're calling it at a sufficient late time? Try printing the component's size to stdout and see what its dimensions are.</p>
<p>Do not call paintComponent() or paint() from the outside. Instead, let your image be created within those (overwritten) methods. Then you can be sure that your image will actually contain the painted content of the component. </p> <p>Here is an example application. The ImagePanel will actually grab the graphics con...
13,907
<p>for a FILE* stream, if I read as much data as possible, feof(stream) returns me non-zero. Then, If I fclose stream, it feof(stream) will continue to returns me a non-zero value? Is it GUARANTEED?</p>
<p>Calling feof() on a closed file is meaningless (actually worse than meaningless - it's undefined so anything can happen).</p> <p>From the C standard:</p> <blockquote> <p>The value of a pointer to a FILE object is indeterminate after the associated file is closed (including the standard text streams).</p> <...
<p>Not for every implementation of feof().</p> <p>In fact, you can't even guarantee that <strong>any</strong> f* call will work after you call fclose.</p>
21,654
<p>I am developing a wizard for a machine that is to be used as a backup of other machines. When it replaces an existing machine, it needs to set its IP address, DNS, WINS, and host name to match the machine being replaced.</p> <p>Is there a library in .net (C#) which allows me to do this programatically?</p> <p>The...
<p>Just made this in a few minutes:</p> <pre><code>using System; using System.Management; namespace WindowsFormsApplication_CS { class NetworkManagement { public void setIP(string ip_address, string subnet_mask) { ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration...
<p>The existing answers have quite broken code. The DNS method does not work at all. Here is code that I used to configure my NIC:</p> <pre><code>public static class NetworkConfigurator { /// &lt;summary&gt; /// Set's a new IP Address and it's Submask of the local machine /// &lt;/summary&gt; /// &lt;p...
25,747
<p>Can you define a macro that accesses a normal variable, but in a read-only fashion (other than defining it as a call to a function)? For example, can the VALUE macro in the following code be defined in such a way that the dostuff() function causes a compile error?</p> <pre><code>struct myobj { int value; } /* Th...
<p>If the variable is always numeric, this works:</p> <pre><code>#define VALUE(x) (x+0) </code></pre> <p>or in the context of your example,</p> <pre><code>#define VALUE(x) (x-&gt;value+0) </code></pre>
<p>Is this a puzzle or is it an engineering task? If it's an engineering task, then there are better ways to get opacity of structures in C. In <a href="http://www.atalasoft.com/cs/blogs/stevehawley/archive/2008/07/02/how-to-build-a-managed-unmanaged-library.aspx" rel="nofollow noreferrer">this blog article</a>, I wro...
17,017
<p>Is there a Ruby equivalent for Python's "is"? It tests whether two objects are identical (i.e. have the same memory location).</p>
<p>Use <code>a.equal? b</code></p> <p><a href="http://www.ruby-doc.org/core/classes/Object.html" rel="noreferrer">http://www.ruby-doc.org/core/classes/Object.html</a></p> <blockquote> <p>Unlike ==, the equal? method should never be overridden by subclasses: it is used to determine object identity (that is, a.equal?...
<p>You could also use <code>__id__</code>. This gives you the objects internal ID number, which is always unique. To check if to objects are the same, try</p> <blockquote> <p><code>a.__id__ = b.__id__</code></p> </blockquote> <p>This is how Ruby's standard library does it as far as I can tell (see <code>group_by</c...
5,617
<p>This free collection library comes from IT University of Copenhagen.</p> <p><a href="http://www.itu.dk/research/c5/" rel="noreferrer">http://www.itu.dk/research/c5/</a></p> <p>There is a video with one of the authors on Channel 9. I am trying to learn how to use these collections and I was wondering whether anyone...
<p>I've used it in the past and there are a couple of notes I must make:</p> <ol> <li>The library is very good, very fast and very useful. It has lots of very nice data structures, some of which I did not know before starting to use this library.</li> <li>It's Open-Source! This is a huge benefit.</li> <li>Sometimes yo...
<p>In addition to that omer van kloeten's points.</p> <p>The open source licence is MIT (comparable to BSD licence) this means that if you need make changes to the library you don't have to open-source the changes. (this might be a problem with some companies). For GPL-type licences this can be a problem.</p>
6,967
<p>Want to use a library for XML schema to code generation and wanted to know if people have a preference between XMLBeans and JAXB. Performance, Schema validation capability, Memory Usage.. Any indicators will help..</p>
<p>My personal preference would be JAXB. It has a more modern approach using annotations and many Java 5 features. XMLBeans on the other hand is still Java 1.4 compliant - if this is required for you. Some other thoughts in no particular oder are:</p> <ul> <li>From Java 6 on JAXB is bundled with the JDK - so it is ava...
<p>I prefer XMLBeans, because it comes with a handy tool called "inst2xsd" which allows you to generate a schema from an XML document. JAXB can only compile schemas, not generate them.</p>
43,467
<p>I wrote a simple add-in for Visual Studio 2008 that opens a dockable window pane. </p> <p><a href="http://www.codeplex.com/ora" rel="noreferrer">You can download the source and a binary installer by clicking here.</a></p> <p>The nature of the add-in means that it is ideally going to stay docked next to where you e...
<p>I faced the some of the same docking issues with TeamReview (<a href="http://www.codeplex.com/TeamReview" rel="noreferrer">http://www.codeplex.com/TeamReview</a>). I can't say why it happens but I can help point you to code that always docs your window in OnStartupComplete. If you have a particular location you want...
<p>Setting the toolwindow visibility to false works really well. thanks JK.</p> <p>To answers JK's question about undocking after debug, I wonder if the devenv.exe /resetaddin switch in the projects debug properties causes that to happen. It certainly resets everything else the addin creates. </p> <p><em>Idea: The /r...
38,702
<p>Granted knowledge is best retained when put into practice, but as programmers I'm sure there's just too much information. Besides annotating your books, what other methods do you use for your own personal knowledge-base so you can have an easily accessible reference?</p> <p>Do you create your own wiki or use softwa...
<p>Blog about it. That way you'll always have it no matter where you are, and that information gets shared with others.</p>
<p>I use codekeep to store my code snippets Occasionaly I store a few notes on google notes too </p>
24,015
<p>a while back I ran across a situation where we needed to display message-boxes to the user for notifications but we could not use MessageBox.Show because it blocks the GUI thread (so nothing on the screen gets updated while the dialog is active). Any suggestions on an alternative?</p> <p>[I coded an alternative at ...
<p>I agree with rslite and Mitchel Sellers. Creating a non-Modal form to display the information needed is the best route to go. If you have multiple messages, you might want to consider putting them into a ListBox and have the user double-click on them to get the full information needing to be displayed.</p>
<p>If you want the MessageBox look and feel just show it in a background thread.</p> <pre><code>ThreadPool.QueueUserWorkItem( (state) =&gt; { MessageBox.Show("Your message"); }); </code></pre> <p>(code not tested)</p>
24,236
<p>How to check, from C#, are files for complex script and rtl languages (Regional and Language settings) installed?</p> <p>Edit: Or is there another way of checking whether right to left text will display correctly in my form?</p> <p>Edit for better explanation (I hope :)) I'm creating an application that will use A...
<p>I'm not sure if this will get you all the way there but, you can query WMI. If you are using .Net, check out the System.Management namespace. You will be interested in...</p> <p>Namespace: root\cimv2 Class: Win32_OperatingSystem Properties: MUILanguages and/or Locale</p>
<p>Thank you for your info. I queried WMI for Win32_OperatingSystem Properties. It returns Win32_OperatingSystem Class with all fields and properties except MUILanguages :(</p> <pre><code>... uint32 MaxNumberOfProcesses; uint64 MaxProcessMemorySize; string MUILanguages[]; //I don't see this field, and all others...
31,180
<p>I'm using .NET 3.5 and I have a class, A, marked as internal sealed partial and it derives from System.Configuration.ApplicationSettingsBase. I then use an instance of this class in the following manner:</p> <pre><code>A A_Instance = new A(); A_Instance.Default.Save(); </code></pre> <p>Why would the Visual C# comp...
<p>You are probably looking for this:</p> <pre><code>private static ServerSettings defaultInstance = ((ServerSettings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new ServerSettings()))); public static ServerSettings Default { get { return defaultInstance; } } </code></pre> <p>This is ...
<p>ApplicationSettingsBase inherits from SettingsBase, neither of which expose a Default property. Judging by the compiler error your class doesn't add one.</p> <p>AFAIK C# does not support any special syntax around the word 'Default' for accessing a property that is marked as the default.</p> <p>What behaviour are ...
23,410
<p>I use MS SQL Server 2005 application roles in an application. I execute the <code>sp_setapprole</code> to start the SPs role and to finish <code>sp_unsetapprole.</code></p> <p>&quot;<strong>connection pooling doesn't work</strong>&quot; with application pooling, and there is no way to react on connection &quot;<str...
<p>I've rolled my own "approle" in the past, it's not too hard. Create a database role for each type of user (manager, casher, clerk, whatever). Create a database user with the group name (manager_user, casher_user, clerk_user etc). Create accounts for your real users and put them in the database roles. Validate your a...
<p>I have not used app roles before, but from what I know about the perf hit is that after setting the application role there is no way to revert to the prev. security context. Thus the connection cannot be reused in pooling. This alone is a huge perf. hit that forces you to think twice about using app roles.</p> <p>H...
26,642
<p>I have a Flash app made up of AS3 components that I am trying to run in Flex. </p> <p>In Flash, after the main component is added to the stage, the loader object (loaderInfo.loader) is null which is fine and I handle that.</p> <p>In Flex, on the applicationComplete event I add the the main component to the stage a...
<p>As the first try, you should download and install Emacs 22.3 for your Windows box and then compare the speed.</p> <p>Speed difference shouldn't be that big after upgrade.</p>
<p>Perhaps it is the big value you assign to fill-column (they suggest less than 80).</p>
44,303
<p>How can I drop sql server agent jobs, if (and only if) it exists?</p> <p>This is a well functioning script for <em>stored procedures</em>. How can I do the same to sql server agent jobs?</p> <pre><code>if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[storedproc]') and OBJECTPROPERTY(id, N'IsProc...
<p>Try something like this:</p> <pre><code>DECLARE @jobId binary(16) SELECT @jobId = job_id FROM msdb.dbo.sysjobs WHERE (name = N'Name of Your Job') IF (@jobId IS NOT NULL) BEGIN EXEC msdb.dbo.sp_delete_job @jobId END DECLARE @ReturnCode int EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'Name of Your Job' <...
<p>If you generate the SQL script for a job (tested with enterprise manager), it automatically builds the check for existance and drop statements for you. Example below: - </p> <pre><code>DECLARE @JobID BINARY(16) DECLARE @ReturnCode INT SELECT @ReturnCode = 0 -- Delete the job with the same name (if it exists...
16,549
<p>I would like to know if it is possible to determine if a function parameter with a default value was passed in Python. For example, how does dict.pop work?</p> <pre><code>&gt;&gt;&gt; {}.pop('test') Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; KeyError: 'pop(): dictionary is ...
<p>I guess you mean "keyword argument", when you say "named parameter". <code>dict.pop()</code> does not accept keyword argument, so this part of the question is moot.</p> <pre><code>&gt;&gt;&gt; {}.pop('test', d=None) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; TypeError: pop(...
<pre><code>def f(one, two=2): print "I wonder if", two, "has been passed or not..." f(1, 2) </code></pre> <p>If this is the exact meaning of your question, I think that there is no way to distinguish between a 2 that was in the default value and a 2 that has been passed. I didn't find how to accomplish such distin...
31,869
<p>The company I'm currently working for is using <a href="http://selenium.openqa.org/" rel="noreferrer">Selenium</a> for Uniting-Testing our User Interface. What do you use to Unit-Test your Web UI and how effective do you find it? </p>
<p>We use Watin at my place of employment, we are a .net shop so this solution made a lot of sense. We actually started with Watir (the original ruby implementation) and switched after. It's been a pretty good solution for us so far</p>
<p>We use <a href="http://watin.sourceforge.net/" rel="nofollow noreferrer">WatiN</a> for system testing, and <a href="http://docs.jquery.com/QUnit" rel="nofollow noreferrer">QUnit</a> for JavaScript unit testing.</p>
2,898
<p>I have a personal wiki that I take notes on. The wiki's pages are in a subversion working copy directory, "pages", and I set their permissions to 664, owned by www-data:www-data. My username is in the "www-data" group, so I can checkin and mess with the pages manually.</p> <p>For a while, I had an issue because e...
<p>Set the "sticky" permissions bit. </p> <pre><code>find -type d -exec chgrp www-data {} + find -type d -exec chmod g+s {} + </code></pre> <p>this will encourage checkout's file creation phase to inherit the directories permissions instead of switching to the person whom last edited it. </p> <p><strong>Edit</str...
<p>I think you are using it wrong. What you could do is still have everything in subversion and have your local working copy separate from the www directory which you develop on.</p> <p>Then just have the www working-copy auto-updated (or exported if you don't want the .svn directories in the www foldeR) for the www-u...
20,334
<p>I have an array of numbers that potentially have up to 8 decimal places and I need to find the smallest common number I can multiply them by so that they are all whole numbers. I need this so all the original numbers can all be multiplied out to the same scale and be processed by a sealed system that will only deal ...
<p>I'd multiply by something sufficiently large (100,000,000 for 8 decimal places), then divide by the <a href="http://en.wikipedia.org/wiki/Greatest_common_divisor" rel="nofollow noreferrer">GCD</a> of the resulting numbers. You'll end up with a pile of smallest integers that you can feed to the other algorithm. After...
<p>What language are you programming in? Something like</p> <pre><code>myNumber.ToString().Substring(myNumber.ToString().IndexOf(".")+1).Length </code></pre> <p>would give you the number of decimal places for a double in C#. You could run each number through that and find the largest number of decimal places(x), then...
8,284
<p>I'm having to start building the architecture for a database project but i really don't know the differences between the engines.</p> <p>Anyone can explain whats the pros and bads of each of these three engines? We'll have to choose one of them and the only thing I actually know about them is this:</p> <ul> <li>My...
<p>A few years ago I had to write a translation engine; you feed it one set of sql and it translates to the dialect of the currently connected engine. My engine works on Postgres (AKA PostgreSql), Ingres, DB2, Informix, Sybase, and Oracle - oh, and ANTS. Frankly, Oracle is my least favorite (more on that below)... Unfo...
<p>See the comparison tables on wikipedia: <a href="http://en.wikipedia.org/wiki/Comparison_of_object-relational_database_management_systems" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Comparison_of_object-relational_database_management_systems</a> &amp;&amp; <a href="http://en.wikipedia.org/wiki/Comparison...
26,627
<p>Can anyone explain what advantages there are to using a tool like MSBuild (or NAnt) to build a collection of projects versus running DevEnv.exe from the command-line?</p> <p>A colleague I had worked with in the past had explained that (at least with older versions of Visual Studio) using DevEnv.exe was much slower ...
<p>One reason is because there's much more to building a product than just compiling it. Tasks such as creating installs, updating version numbers, creating escrows, distributing the final packages, etc. can be much easier because of what these tools (and their extensions) provide. </p> <p>While you could do all th...
<p>We are experimenting with switching from DevEnv to a tool (Visual Build Pro) that uses MsBuild under the hood and we got a "Reference required to assembly 'System.Drawing..." error for a project which doesn't need it and which builds fine in Visual Studio.</p>
17,090
<p>I have a couple of tables that I want to map to classes. The tables look like this:</p> <pre><code>Asset --------- AssetId AssetName Product --------- ProductId ProductName AssetId Disposal --------- DisposalId AssetId DisposalDate </code></pre> <p>Basically what I want to do is join the Product Table to the Dis...
<p>Have you got your Disposals mapped to Products?</p> <p>Your schema doesn't unique relate a Disposal to a Product. A Disposal can only relate to an Asset, not a Product.</p> <p>You schema says to me that an Asset has many Products, and an Asset has many Disposals. There's nothing that says a Disposal is for a parti...
<p>Have you got your Disposals mapped to Products?</p> <p>Your schema doesn't unique relate a Disposal to a Product. A Disposal can only relate to an Asset, not a Product.</p> <p>You schema says to me that an Asset has many Products, and an Asset has many Disposals. There's nothing that says a Disposal is for a parti...
39,519
<p>Can this be done by setting a property? </p> <p>I'd prefer that approach then to remove all security before re-adding it. (As this may have other consequences.)</p> <p>Another option I can think of is to replace the particular webpart dll with a temporary one, and restart the .net process, but that's not an appro...
<p>Go to Site Actions -> Edit Page You get all the web parts edited. Click on the "Edit" dropdown of the Web Part you want to disable and choose "Close".</p> <p>The web part disappears, but don't fear! It's not gone for good! </p> <p>To have it back:<br> -> click to Add a new Web Part -> Advanced Web Part Gallery and...
<p>write code to set a value in property bag of the site, set the value through the code and in page lode of the web part check for the value of the property bag if set show the content else just skip. hope you understood if not let me know i will make it clear.</p>
11,046
<p>How to count distinct values in a node in XSLT?</p> <p>Example: I want to count the number of existing countries in Country nodes, in this case, it would be 3.</p> <pre><code>&lt;Artists_by_Countries&gt; &lt;Artist_by_Country&gt; &lt;Location_ID&gt;62&lt;/Location_ID&gt; &lt;Artist_ID&gt;212&lt...
<p>If you have a large document, you probably want to use the "Muenchian Method", which is usually used for grouping, to identify the distinct nodes. Declare a key that indexes the things you want to count by the values that are distinct:</p> <pre><code>&lt;xsl:key name="artists-by-country" match="Artist_by_Country" u...
<p>If you have control of the xml generation on the first occurence of a country you could add an attribute to the country node such as distinct='true' flag the country as "used" and not subsequently add the distinct attribute if you come across that country again.</p> <p>You could then do</p> <pre><code>&lt;xsl:for-...
18,484
<p>My development server (CentOS 5) is running Subversion 1.4.2, and I wish to upgrade it to 1.5. I have read in various blogs and documents scattered around the web that this may be done by using RPMForge. I have followed the instructions found on <a href="http://wiki.centos.org/AdditionalResources/Repositories/RPMF...
<p>What you are trying to do is to replace a "core" package (one which is contained in the CentOS repository) with a newer package from a "3rd party" repository (RPMForge), which is what the priorities plugin is designed to prevent.</p> <p>The RPMForge repository contains both additional packages not found in CentOS, ...
<p>its up to v 1.4.6 in Dag's repository.</p> <p>You can try the one from <a href="https://admin.fedoraproject.org/pkgdb/packages/name/subversion" rel="nofollow noreferrer">Fedora's repo</a> or have a bit of patience for the main repositories to upgrade it.</p> <p>Making it from source is easy, read the INSTALL file ...
12,217
<p>I was wondering if there was an easy way in SQL to convert an integer to its binary representation and then store it as a varchar.</p> <p>For example 5 would be converted to "101" and stored as a varchar.</p>
<p>Following could be coded into a function. You would need to trim off leading zeros to meet requirements of your question.</p> <pre><code>declare @intvalue int set @intvalue=5 declare @vsresult varchar(64) declare @inti int select @inti = 64, @vsresult = '' while @inti&gt;0 begin select @vsresult=convert(cha...
<p>How about this...</p> <pre><code>SELECT number_value ,MOD(number_value / 32768, 2) AS BIT15 ,MOD(number_value / 16384, 2) AS BIT14 ,MOD(number_value / 8192, 2) AS BIT13 ,MOD(number_value / 4096, 2) AS BIT12 ,MOD(number_value / 2048, 2) AS BIT11 ,MOD(number_value / 1024, 2) AS BIT10 ,MOD(number_value / 512, 2)...
15,468
<p>What is the best way to programmatically send an SMS text message?</p> <p>Are there any free Web Service based SMS gateways?</p> <p>I know that if I happen to know the user's carrier (Sprint, AT&amp;T, etc), I can send an <a href="http://en.wikipedia.org/wiki/SMS_gateways" rel="noreferrer">SMS by emailing an addre...
<p>Use <a href="http://www.twilio.com/" rel="noreferrer">http://www.twilio.com/</a></p> <p>They have a REST interface to send SMS's and even to establish phone calls or receive phone calls.</p> <p>You even get 30$ credits to try it out.</p> <p>Def. the cheapest solution you will find.</p>
<p>Sorry, after re-reading your question i realized this is not the answer your looking for. However this is what i did for my command line program. There's a website where if you put in the telephone number it gives you the carrier. So when i entered my number it screen scraped the website, got the carrier and if the ...
2,628
<p>Some members of the team are having problems programming together. Different gender, different culture, different age. How to deal with those problems? - Do not pair them together, or - Pair them together and let them come to a "golden middle"</p>
<p>Pair programming is based on the idea that the interaction of two programmers adds value. If this is not true, change the pairs... let them choose. Programming should be fun!</p>
<p>Another approach is to continually switch your pairs within the scrum. Have a timer which might be set for 1/2/3 hours. When the bell goes off, rotate your pairs. This has a few effects:</p> <ul> <li>Two people don't get stuck pairing together for a long time</li> <li>Your developers will get to rotate through y...
13,720
<p>I have a question about css selectors.</p> <p>Say I have the following html </p> <pre><code>&lt;div class="message"&gt; &lt;div class="messageheader"&gt; &lt;div class='name'&gt;A news story&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>In the css I could refer to the <code>class</code> called <c...
<p>If you are only interested in the initial scenario using .name is just fine. In fact, best practice with CSS is to always start more generic and focus as you go. </p> <p>also, doing things like div.* are unnecessary unless you have the same class on a different element and want to make them different. If you are ...
<p>I find that using both methods together can help the logical organisation of your CSS. Use the generic ".class" for properties that you want to apply to ALL items of that class and the more specific "p.class" for a specific type object of the class. For example: </p> <pre><code>&lt;style&gt; div.product { float: le...
41,505
<p>Having recently come across <a href="http://elasticdog.com/2008/11/beginning-factor-introduction/" rel="noreferrer">this introduction to Factor</a>, I've been a bit curious to learn more. Aside from the official FAQ mentioned there, do you have resources for learning the language (as well as the stack-based &quot;pa...
<p>Factor is heavily inspired by Forth and other stack languages. It also grabs ideas from Lisp, and Smalltalk. From what I've read online, it's not necessary to learn any of those language before learning Factor. It won't hurt if you do, however :) </p> <p>The biggest problems I've run into is the youthfulness of th...
<p>I've been teaching myself Factor recently - I actually found Forth as a good afternoon's introduction to the concept of stack based languages (and as a bit of a software archaeologist, it's fun to step back a few years for a history lesson).</p> <p>To that end I don't think it does any harm to take a few hours to i...
43,195
<p>I've tried to do this several times with no luck. After reading <a href="https://stackoverflow.com/questions/1451/what-is-the-best-way-to-handle-multiple-permission-types#1477">this post</a>, it made me interested in doing this again. So can anyone tell me why the following doesn't work?</p> <pre><code>&lt;?php ...
<p>Use the bitwise OR operator (|) to set bits, use the AND operator (&amp;) to check bits. Your code should look like this:</p> <pre><code>&lt;?php $guest = 1; $editor = 2; $admin = 4; $user = $editor; if( $user &amp; ($editor | $admin) ) { echo "Test"; } ?&gt; </code></pre> <...
<p>In my opinion this doesn't scale well. I haven't actually tried using it on a large scale project, but a CMS sounds way to complicated to use this on.</p>
3,787
<p>I have a web site using apache httpd as the server and mysql as the backend. It publishes a "thought for the day" that has gotten so popular that the server is crashing due to the number of requests. Since the same page is been requested (the thought only changes once a day), is it possible to put a caching server i...
<p>For slow changing pages, a cache will definitely reduce CPU usage; but in your extreme case, where the page changes once a day, and it's perfectly predictable, it would be far easier to use a simple and fast static file server (<a href="http://www.lighttpd.net/" rel="nofollow noreferrer">lighthttp</a>, <a href="http...
<p>You could also try <a href="http://www.danga.com/memcached/" rel="nofollow noreferrer">memcached</a>. That's what my company uses and I think LiveJournal uses it too. It caches DB requests and makes a serious dent in DB access.</p>
20,589
<p>It's 2008, and I'm still torn on this one. So I'm developing a web method that needs a complex type passed into it and returned from it. The two options I'm toying with are:</p> <ol> <li><p>Pass and return <em>actual</em> business objects with both data and behavior. When wsdl.exe is run, it will automatically c...
<p>I'd do a hybrid. I would use an object like this</p> <pre><code>public class TransferObject { public string Type { get; set; } public byte[] Data { get; set; } } </code></pre> <p>then i have a nice little utility that serializes an object then compresses it.</p> <pre><code>public static class CompressedSe...
<blockquote> <p><strong>Darren</strong> wrote: I'd do a hybrid. I would use an object like this...</p> </blockquote> <p>Interesting idea... passing a serialized version of the object instead of the (wsdl-ed) object itself. In a way, I like its elegance, but in another way, it seems to defeat the purpose of exposing...
3,404
<p>What makes a module/service/bit of application functionality a particularly good candidate for an OSGi module? </p> <p>I'm interested in using <a href="http://en.wikipedia.org/wiki/OSGi" rel="noreferrer">OSGi</a> in my applications. We're a Java shop and we use Spring pretty extensively, so I'm leaning toward using...
<p>Well, since you can not have one part OSGi and one part non-OSGi you'll need to make your entire app OSGi. In its simplest form you make a single OSGi bundle out of your entire application. Clearly this is not a best practice but it can be useful to get a feel for deploying a bundle in an OSGi container (Equinox, Fe...
<p>I really like the <a href="http://felix.apache.org/site/tutorials-examples-and-presentations.html" rel="nofollow noreferrer">Apache Felix tutorials</a>. However, I think in general leveraging OSGi in your application isn't one of those "let's use this framework, because it's hype" decision. It's more of a design que...
3,686
<p>I use RCF with boost.serialization (why use RCF's copy when we already use the original?) It works OK, but when an exception is thrown in the server, it's not passed correctly to the client. Instead, I get an RCF::SerializationException quoting an <code>archive_exception</code> saying "class name too long". When I c...
<p>Here's a patch given by Jarl at <a href="http://www.codeproject.com/KB/threads/Rcf_Ipc_For_Cpp.aspx?msg=2739150#xx2730536xx" rel="nofollow noreferrer">CodeProject</a>:</p> <p>In RcfServer.cpp, before the line where RcfServer::handleSession() is defined (around line 792), insert the following code:</p> <pre><code>v...
<p>According to Jarl it works, check <a href="http://www.codeproject.com/KB/threads/Rcf_Ipc_For_Cpp.aspx?fid=248794&amp;df=90&amp;mpp=25&amp;noise=3&amp;sort=Position&amp;view=Quick&amp;fr=101&amp;select=2365783" rel="nofollow noreferrer">codeproject</a> for a question and answer with sample code:</p>
8,830
<p>These two methods exhibit repetition: </p> <pre><code>public static Expression&lt;Func&lt;Foo, FooEditDto&gt;&gt; EditDtoSelector() { return f =&gt; new FooEditDto { PropertyA = f.PropertyA, PropertyB = f.PropertyB, PropertyC = f.PropertyC, PropertyD = f.PropertyD, P...
<p>Well, I have a <em>really horrible</em> way you could do it.</p> <p>You could write a method which used reflection (bear with me!) to work out all the properties for a particular type, and built a delegate (using Reflection.Emit) to copy properties from that type to another. Then use an anonymous type to make sure ...
<p>The repetition is in the names, but C# has no idea that PropertyA in one class is connected with PropertyA in another. You have to make the connection explicitly. The way you did it works fine. If you had enough of these, you might consider using reflection to write one method that could do this for any pair of clas...
27,452
<p>The following html code works in Firefox, but for some reason fails in IE (Label2 is not shown). Is that a bug or I miss something?</p> <p>Any help would be appreciated.</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; &lt;html&gt; &lt;head&gt; ...
<h3>Cause:</h3> <p>Per MSDN, the <a href="http://msdn.microsoft.com/en-us/library/ms536912(VS.85).aspx" rel="nofollow noreferrer">change event</a> is</p> <blockquote> <p>...fired when the contents are committed and not while the value is changing. For example, on a text box, this event is not fired while the user is ty...
<p>Change the .change event to .click event. the result in both browser is the same. in IE when you click the checkbox, blur didn't occur.</p>
48,154
<p>I have the following struct in C++:</p> <pre><code>#define MAXCHARS 15 typedef struct { char data[MAXCHARS]; int prob[MAXCHARS]; } LPRData; </code></pre> <p>And a function that I'm p/invoking into to get an array of 3 of these structures:</p> <pre><code>void GetData(LPRData *data); </code></pre> <p>In ...
<p>I would try adding some attributes to your struct decloration</p> <pre><code>[StructLayout(LayoutKind.Sequential, Size=TotalBytesInStruct),Serializable] public struct LPRData { /// char[15] [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 15)] public string data; /// int[15] [MarshalAsAttribute(UnmanagedTy...
<p>The PInvoke Interop Assistant may help. <a href="http://clrinterop.codeplex.com/releases/view/14120" rel="nofollow noreferrer">http://clrinterop.codeplex.com/releases/view/14120</a></p>
22,826
<p>I wondered if anyone had successfully managed, or knew how to automate the Safari web browser on the Windows platform.</p> <p>Ideally I would like to automate Safari in a similar way to using <a href="http://msdn.microsoft.com/en-us/library/aa741317.aspx" rel="nofollow noreferrer">mshtml</a> for Internet Explorer. ...
<p>you might check my post here where I am using the method described above to automate Chrome in C#</p> <p><a href="http://markcz.wordpress.com/2012/02/18/automating-chrome-browser-from-csharp/" rel="nofollow">http://markcz.wordpress.com/2012/02/18/automating-chrome-browser-from-csharp/</a></p> <p>Martin</p>
<p><a href="http://selenium.openqa.org/" rel="nofollow noreferrer">Selenium</a> has been very useful for me for compatibility testing.</p>
8,553
<p>I've recently started with Python, and am enjoying the "batteries included" design. I'e already found out I can import time, math, re, urllib, but don't know how to know that something is builtin rather than writing it from scratch.</p> <p>What's included, and where can I get other good quality libraries from?</p>
<p>Firstly, the <a href="https://docs.python.org/2/library/index.html" rel="nofollow noreferrer">python libary reference</a> gives a blow by blow of what's actually included. And the <a href="http://docs.python.org/modindex.html" rel="nofollow noreferrer">global module index</a> contains a neat, alphabetized summary o...
<p>This is not directly related to your question, but when you're in the python console, you can call help() on any function and it will print its documentation.</p> <p>also, you can call dir() on any module or object and it will list all of its attributes, including functions.</p> <p>This useful for inspecting conte...
42,692