instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>My implementation of httpclient occasionally throws an exception when calling doGetConnection(). However, I have the following timeout set</p> <pre><code>_moHttpClient.setHttpConnectionFactoryTimeout(30000); </code></pre> <p>it looks almost like my timeout is not being picked up. Is there anywhere else I need to s...
<pre><code> HttpConnectionManagerParams cmparams = new HttpConnectionManagerParams(); cmparams.setSoTimeout(10000); cmparams.setTcpNoDelay(true); HttpConnectionManager manager = new SimpleHttpConnectionManager(); manager.setParams(cmparams); params = new HttpClientParams(); params.setSoTimeou...
<blockquote> <p>cmparams.setSoTimeout(10000);</p> </blockquote> <p>This one is for all HttpClient by default.</p> <blockquote> <p>params.setSoTimeout(5000);</p> </blockquote> <p>And this one is for a particular httpclient.</p>
16,045
<p>Does anyone know of a simple web app that supports running ant tasks? Alternatively it could run command line programs. I need to allow the user to choose parameters for running the ant task. I effectively want a web interface to run the ant task and provide any parameters.</p> <p>I can write one but this is gen...
<p>You could give <a href="http://www.anthillpro.com/html/products/anthillos/download.html" rel="nofollow noreferrer">Anthill</a> a shot. They have an open source version. This will periodically check your source code repository, and run a specified ant task any time the code base changes. You can also manually trig...
<p>You could put this in a PHP-file:</p> <pre><code>echo shell_exec('ant'); </code></pre> <p>It would run ant and return the output to the browser. </p>
29,776
<p>I am looking for an efficient means to partially check the integrity of "large" data sets over a slow transfer medium. This seems like a common problem as file sizes grow out of proportion to transfer rates. </p> <p>For example, for concrete numbers, a terabyte of data over USB2. Checking that this data is still v...
<p>Transfers take place over USB2, right? Therefore you should know that:</p> <ul> <li>USB communication are in form of packets, with a payload up to 1024 bytes for high-speed transfers and a 16-bit CRC.</li> <li>Each packet is acknowledged and potentially retransmitted.</li> </ul> <p>You have to take into account th...
<p>How about storing hash or checksum values for runs of data within the file? You would then only have to read in a restricted portion of the data for a limited validation of the file content.</p>
40,231
<p>I've got an app that my client wants to open a kiosk window to ie on startup that goes to their corporate internet. Vb isn't my thing but they wanted it integrated into their current program and I figured it would be easy so I've got</p> <pre><code>Shell ("explorer.exe http://www.corporateintranet.com") </code></p...
<p>If you would like to use -k, you will probably want to call <code>iexplore.exe</code> instead of <code>explorer.exe</code>.</p>
<p>You have it right now but I think you are missing the closing quote after iexplore.exe</p> <p>You may also want to take out the [space]-k, set the zoom level to what will work for you in kiosk mode and then put the [space]-k back in. I am guessing there is a parameter or argument as they call it to pass the opening...
20,669
<p>I have an ASP.Net application which as desired feature, users would like to be able to take a screenshot. While I know this can be simulated, it would be really great to have a way to take a URL (or the current rendered page), and turn it into an image which can be stored on the server.</p> <p>Is this crazy? Is t...
<p>I can tell you right now that there is no way to do it from inside the browser, <strong>nor should there be</strong>. Imagine that your page embeds GMail in an iframe. You could then steal a screenshot of the person's GMail inbox!</p> <p>This could be made safe by having the browser "black out" all iframes and emb...
<p>You could try a browser plugin like <a href="http://www.ie7pro.com/" rel="nofollow noreferrer">IE7 Pro</a> for Internet Explorer which allows you to save a screenshot of the current site to a file on disk. I'm sure there is a comparable plugin for FireFox out there as well.</p>
27,151
<p>Whats the most efficient way of selecting total number of records from a large table? Currently, Im simply doing</p> <pre><code>$result = mysql_query("SELECT id FROM table"); $total = mysql_num_rows($result) </code></pre> <p>I was told this was not very efficient or fast, if you have a lot of records in the table....
<p>You were told correctly. mysql can do this count for you which is much more efficient.</p> <pre><code>$result = mysql_query( "select count(id) as num_rows from table" ); $row = mysql_fetch_object( $result ); $total = $row-&gt;num_rows; </code></pre>
<p>Just wanted to note that <code>SHOW TABLE STATUS</code> returns a <code>Rows</code> column, though I can't speak to its efficiency. Some light Googling turns up reports of slowness in MySQL 4 over two years ago. Might make for interesting time trials.</p> <p>Also note the <a href="http://dev.mysql.com/doc/refman/5....
14,232
<p>Looking for sites which offer templates for creating styled table-based web page forms. </p> <p>Similar to css-based forms at: <a href="http://www.smashingmagazine.com/2006/11/11/css-based-forms-modern-solutions/" rel="nofollow noreferrer">http://www.smashingmagazine.com/2006/11/11/css-based-forms-modern-solutions/...
<p>This is like asking for an example of GOTO statement best practices. Your just asking for trouble, no matter the intent!</p>
<p>I don't know about sites which offer templates, but 37 Signals use tables with their forms. Like <a href="https://signup.37signals.com/basecamp/Max/signup/new?source=google-basecamp" rel="nofollow noreferrer">this one</a>.</p>
23,363
<p>I'd like to call methods of my DAOs by AJAX. I'm quite new in that so I would like to ask what is the best way to do that. Is it possible to publish my beans as web services and call them with e.g. jQuery? I think it is not possible :) I've also read about Direct Web Remoting but I don't know which way to go... </p>...
<p>Rather than exposing your DAO beans directly, you should create some Spring MVC controller beans, and call those from the client-side (using AJAX). Ideally, the controllers should not call the DAOs directly, but should instead call service beans (and the service beans should call the DAOs). One advantage of this app...
<p>You have to expose your DAO's or beans by means of http. Typically you create a layer above the DAO layer to expose your services through HTTP, which are available to any AJAX framework such as jQuery. What jQuery and other frameworks ends up doing is using a special asynchronous request called XMLHttpRequest and th...
22,841
<p>I was reading a MS Excel help article about pivotcache and wonder what they mean by <em>OLE DB and ODBC sources</em></p> <blockquote> <p>...You should use the CommandText property instead of the SQL property, which now exists primarily for compatibility with earlier versions of Microsoft Excel. If you use...
<p>According to <a href="https://books.google.ca/books?id=JTKX7OUqCEMC" rel="nofollow noreferrer"><em>ADO: ActiveX Data Objects</em>, a book by Jason T. Roff, published by O'Reilly Media in 2001</a> (excellent diagram here), he says precisely what MOZILLA said.</p> <p>(directly from page 7 of that book)</p> <blockquote...
<p>To know why M$ invents OLEDB, you can't compare OLEDB with ODBC. Instead, you should compare OLEDB with DAO,RDO, or ADO. The latter largely relies on SQL. However, OLEDB relies on COM. But ODBC is already there many years, so there's a OLEDB-ODBC bridges to remedy this. I think there's a big picture when M$ invents ...
12,872
<p>I am using TortoiseSVN for my Subversion repository held on a USB drive. When I move from one PC to another, is there a way to automatically identify that files are out of date (without using the Check for Modifications menu). It would be nice just to be able to see that the folder on my hard drive did not match tha...
<p>Try creating a file called <a href="http://dailycupoftech.com/usb-drive-autoruninf-tweaking/" rel="nofollow noreferrer">"autorun.inf"</a> in the root directory of your USB key. Then fill it with the following lines:</p> <pre><code>[autorun] open=CheckForMods.bat </code></pre> <p>Then create a <code>CheckForMods.ba...
<p>Create a batch file which automatically update your local working copy when the USB key is connected.</p>
26,939
<p>My local library has a 3D printer (Lulzbot Mini) for patrons to use. The prints are limited to 4 hours and if I go after work I really only have two hours before the Library closes. The software at the Library will give an estimated time, but I would like to be able to estimate the time before I get there.</p> <p>C...
<p>There is no way to estimate the print time of an STL file directly.</p> <p>The print time is based on the number of instructions in the g-code file plus the time it takes to move the effector (the hot end) around the build area. The only way to compute that is to know what settings their slicer is using and then sl...
<p>There is no way to estimate the print time of an STL file directly.</p> <p>The print time is based on the number of instructions in the g-code file plus the time it takes to move the effector (the hot end) around the build area. The only way to compute that is to know what settings their slicer is using and then sl...
1,427
<p>I am looking at depency injection, I can see the benefits but I am having problems with the syntax it creates. I have this example</p> <pre><code>public class BusinessProducts { IDataContext _dx; BusinessProducts(IDataContext dx) { _dx = dx; } public List&lt;Product&gt; GetProducts() { ...
<p>I use a factory for my context and inject it, providing a suitable default if the provided factory is null. I do this for two reasons. First, I use the data context as a unit of work scoped object so I need to be able to create them when needed, not keep one around. Second, I'm primarily using DI to increase tes...
<p>you can also look at <a href="http://www.castleproject.org/container/index.html" rel="nofollow noreferrer">windsor</a> for IoC .</p>
46,837
<p>So which is better. Do we start letting Tests design our code. Do we start introducing constructor injection for dependencies just to make code testable? or do we use the "override" protected method &amp; sub class the class under test.</p>
<p>I generally think that testable code is good code. For code to be testable, you need better decoupling so each component can be tested in isolation with a test harness. However, there shouldn't be code in the implementation that is just used by the unit tests. </p> <p>Also, keep in mind that what you need to test i...
<p>I mostly agree with Staale, well-designed code should be testable.<br> I don't use constructor injection or derive classes for testing. I believe using 'service locators' is the right way to do dependency injection.</p>
22,566
<p>Imagine you homebrew a custom gui framework that <em>doesn't</em> use windows handles (compact framework, so please don't argue with "whys"). One of the main disadvantages of developing such a framework is that you lose compatability with the winform designer.</p> <p>So my question is to all of you who know a lot a...
<pre><code>select * from information_schema.tables WHERE OBJECTPROPERTY(OBJECT_ID(table_name),'IsMSShipped') =0 </code></pre> <p>Will exclude dt_properties and system tables</p> <p>add </p> <pre><code>where table_type = 'view' </code></pre> <p>if you just want the view</p>
<pre><code>select * from information_schema.tables where table_type = 'view' </code></pre>
5,325
<p>After installing the F# September CTP (1.9.6.2), Visual Studio 2008 frequently gives an error "Microsoft Visual C# IntelliSense has stopped working" which promptly crashes all of Visual Studio. I tried the tips mentioned in a <a href="https://stackoverflow.com/questions/178846/visual-studio-intellisense-stopped-wor...
<p>Edit after reading some more of the source:</p> <p>You still need to subclass PatternLayout, but the method you want to override is ignoresThrowable(): it should return false, which will prevent the appender from writing the Throwable (it assumes that the layout has done so already).</p> <p>No way to specify this ...
<p>If you can change the source code, then another option is available for consideration.</p> <p>In my applications, I always and only log FATAL messages from my applications entry point (e.g., "main()"), since I only know that they are fatal if I am about to exit the application because of them.</p> <p>Therefore, in...
45,351
<p>I'm dealing with huge glassfish log files (in windows, eek!) and well ... Wordpad isn't cutting it. </p> <p>Are there any tools out there that can handle these log files in a more intelligent manner? Functionality that would be welcome:</p> <ul> <li>View all lines of a certain log level (info, warning, severe)</li...
<p>On Windows I'd still go perl or awk. Download and install <a href="http://cygwin.com" rel="nofollow noreferrer">cygwin</a>, then use awk or whatever you are familiar with. awk has the time functions needed for filtering, and features such as <code>getline</code> for log file navigation.</p> <p>Ex: Exception occuren...
<p>I use Excel for parsing log files. If you use tab-delimited log files this can work great. The filtering and sorting features of Excel lend themselves well to logfile analysis.</p>
16,896
<p>I'm slowly moving from PHP5 to Python on some personal projects, and I'm currently loving the experience. Before choosing to go down the Python route I looked at Ruby. What I did notice from the ruby community was that monkey-patching was both common and highly-regarded. I also came across a <strong>lot</strong> of ...
<p>There's a difference between monkey-patching (overwriting or modifying pre-existing methods) and simple addition of new methods. I think the latter is perfectly fine, and the former should be looked at suspiciously, but I'm still in favour of keeping it.</p> <p>I've encountered quite a few those problems where a th...
<p>Monkey-patching is just plain <em>wrong</em>, IMHO. I've not come across the open/closed principle you mention before, but it's a principle I've long held myself, I agree with it 100%. I think of monkey-patching as a code-smell on a larger scale, a coding-philosophy-smell, as it were.</p>
37,421
<p>I have compression enabled within IIS7 and it works as expected on all responses except for those constructed by ASP.NET AJAX. I have a web service that provides data to the client. When the web service is called directly, it is properly compressed. However, when it is called via ASP.NET AJAX, the JSON response i...
<p>IIS7 uses the content-encoding to decide whether to compress the response (assuming of course that the browser can accept gzip). They're set in applicationHost.config, and by default the list is</p> <pre><code>&lt;dynamicTypes&gt; &lt;add mimeType="text/*" enabled="true" /&gt; &lt;add mimeType="message/*"...
<p>Last I checked, the gzipping was something that IIS does (when setup correctly) - and of course when the browser sends the required headers</p>
30,277
<p>Is there an easy way to discover a File's creation time with Java? The File class only has a method to get the "last modified" time. According to some resources I found on Google, the File class doesn't provide a getCreationTime() method because not all file systems support the idea of a creation time.</p> <p>The...
<p>With the release of Java 7 there is a built-in way to do this:</p> <pre><code>Path path = Paths.get("path/to/file"); BasicFileAttributes attributes = Files.readAttributes(path, BasicFileAttributes.class); FileTime creationTime = attributes.creationTime(); </code></pre> <p>It is important to note that not all opera...
<p>This is a basic example in <code>Java</code>, using <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/attribute/BasicFileAttributes.html" rel="nofollow"><strong><code>BasicFileAttributes</code></strong></a> class:</p> <pre><code> Path path = Paths.get("C:\\Users\\jorgesys\\workspaceJava\\myfile.txt...
5,253
<p>I've got 2 remote databases as part of a query </p> <pre><code>select p.ID,p.ProjectCode_VC,p.Name_VC,v.* FROM [serverB].Projects.dbo.Projects_T p LEFT JOIN [serverA].SOCON.dbo.vw_PROJECT v on p.ProjectCode_VC = v.PROJ_CODE </code></pre> <p>The problem is that serverA uses collation <code>Latin1_General_BIN</code>...
<p>Just add the collation to your select, like:</p> <pre><code>select p.ID, p.ProjectCode_VC, p.Name_VC, v.* FROM [serverB].Projects.dbo.Projects_T p LEFT JOIN [serverA].SOCON.dbo.vw_PROJECT v on p.ProjectCode_VC collate Latin1_General_Bin = v.PROJ_CODE </code></pre> <p>or the other way around. So...
<p>Or you can use a more generic query like this:</p> <pre><code>select * from profile, userinfo where profile.custid collate database_default = userinfo.custid collate database_default </code></pre>
32,316
<p>I've downloaded the svntask for ant from tigris.org, so it is the "official" one.</p> <p>I have a simple task to update my entire project</p> <pre><code>&lt;target name="prepare"&gt; &lt;svn username="user" password="pass"&gt; &lt;update&gt; &lt;fileset dir="."/&gt; ...
<p>By using the nested <code>&lt;fileset&gt;</code> the command ends up calling <code>update</code> for every file in the current directory hierarchy. That's probably why it takes two hours.</p> <p>Try using the <code>dir</code> attribute of the <code>update</code> task:</p> <pre><code> &lt;svn username="user" pa...
<p>So if you just run "ant prepare" it takes 2 hrs? Or is this 2 hr duration only under special conditions like your build machine?</p> <p>Have you tried using the task for comparison, to try and isolate if it is Ant vs. the particular task?</p>
49,520
<p>I'm looking to replace a couple of machines in the office with a more powerful multi-processor machine running either VMware or Microsoft's Hyper-V with a view to hosting a mix of Windows Server 2003, Windows Server 2008 and Linux operating systems. The machines are used mainly for testing ASP.Net or Perl web sites....
<p>VMware did recently release a free version of ESXi recently.</p> <p>VMware has a few advantages:<br> 1. VMware virtual machines are portable across different types of hardware. IIRC, Hyper-V uses the drivers from the Host OS.<br> 2. VMware virtual machines are portable across different VMware products (although yo...
<p><em>Necros the thread</em> Just wanted to add my 2c since the last post has been a while.</p> <p>I have been using VMWare Server since version 1.6 all the way up to 2.0.</p> <p>Just out of curiosity, I tried out Hyper-V, and there's a real definitive performance gain. Hyper-V is plain faster.</p> <p>Switched over...
5,923
<p>I'm currently working on a project that depends on me providing a path to a file (eg. <code>C:\Path.pth</code>). Now, I had everything working yesterday by calling my <code>std::string</code> with:</p> <pre><code>std::string path(`"C:\\Path.pth`"); </code></pre> <p>But now it doesn't work. It throws a <code>bad_al...
<p>As your error suggest, the problem is due to <strong>memory allocation</strong> (i.e. the bad_alloc exception).</p> <p>So either you have no more memory (unlikely) or you have a buffer overrun somewhere before (quite likely in my opinion) or some other memory issues like double free.</p> <p>In short, you do someth...
<p>Assuming your double-backslash is correct, I'd guess you're running on Vista?</p> <p>Vista won't let your write into the root directory of the C drive by default. Try one of the following:</p> <ul> <li>Turn off UAC, or</li> <li>Run your application as "Administrator", or</li> <li>Write into a subdirectory.</li> </...
21,414
<p>Does anyone have a suggestion for where to find archives or collections of everyday English text for use in a small corpus? I have been using Gutenberg Project books for a working prototype, and would like to incorporate more contemporary language. A <a href="https://stackoverflow.com/questions/122595/nlp-qualitat...
<ul> <li>Use the <a href="http://en.wikipedia.org/wiki/Wikipedia:Database_download" rel="noreferrer">Wikipedia dumps</a> <ul> <li>needs lots of cleanup</li> </ul></li> <li>See if anything in <a href="http://prdownloads.sourceforge.net/nltk/nltk-data-0.9.5.zip" rel="noreferrer">nltk-data</a> helps you <ul> <li>the cor...
<p>You've covered the obvious ones. The only other areas that I can think of too supplement:</p> <p>1) News articles / blogs.</p> <p>2) Magazines are posting a lot of free material online, and you can get a good cross section of topics.</p>
16,615
<p><a href="https://stackoverflow.com/questions/48496/how-to-teach-a-crash-course-on-c">This post</a> reference to the One Definition Rule.</p> <p><a href="http://en.wikipedia.org/wiki/One_Definition_Rule" rel="nofollow noreferrer">Wikipedia is pretty bad on explaining how to implement it</a></p> <p>Where can I find ...
<p>The one definition rule basically means that a variable/function can only be located at one place in address space of the compiled executable. One way to think of it is while you compile, there is an array of memory to be used in the compiled program (object code), and a lookup table to reference variable/function l...
<p>The easiest way to comply with the one definition rule is to put the definition in a .cpp file instead of the header.</p> <p>People sometimes put definitions into headers using macros and/or preprocessor conditionals to make the object or function defined only in one compilation unit. But it's easier usually (and ...
49,781
<p>It's surprising how difficult it is to find a simple, concise answer to this question:</p> <ol> <li>I have a file, foo.zip, on my website</li> <li>What can I do to find out how many people have accessed this file?</li> <li>I could use Tomcat calls if necessary</li> </ol>
<p>Or you could parse the log file if you don't need the data in realtime.</p> <pre><code>grep foo.zip /path/to/access.log | grep 200 | wc -l </code></pre> <p>In reply to comment:</p> <p>The log file also contains bytes downloaded, but as someone else pointed out, this may not reflect the correct count if a user can...
<p>Use the logs--each GET request for the file is another download (unless the visitor stopped the download partway through for some reason).</p>
19,113
<p>Everyone has this huge massively parallelized supercomputer on their desktop in the form of a graphics card GPU.</p> <ul> <li>What is the "hello world" equivalent of the GPU community?</li> <li>What do I do, where do I go, to get started programming the GPU for the major GPU vendors?</li> </ul> <p>-Adam</p>
<p>Check out CUDA by NVidia, IMO it's the easiest platform to do GPU programming. There are tons of cool materials to read. <a href="http://www.nvidia.com/object/cuda_home.html" rel="noreferrer">http://www.nvidia.com/object/cuda_home.html</a> <br /></p> <p>Hello world would be to do any kind of calculation using GPU.<...
<p>Try <a href="http://blog.beef.de/thesis/" rel="nofollow noreferrer">GPU++</a> and <a href="http://libsh.org/wiki/index.php/How_Sh_Works" rel="nofollow noreferrer">libSh</a></p> <p>LibSh link has a good description of how they bound the programming language to the graphics primitives (and obviously, the primitives t...
27,075
<p>I have an ASP.NET application which tracks statistics by creating and writing to custom performance counters. Occasionally, I see in the error logs that indicate that the counters have failed to open because they had already been used in the current process. I presume this is due to my .NET appdomain having been r...
<p>IIRC, IIS will not make sure that your first AppDomain is closed before it starts the second, particularly when you are recyclying it manually or automatically. I believe that when a recycle is initiated, the second AppDomain is instantiated first, and once that succeeds, new incoming requests are directed towards i...
<p>I am no expert with custom counters, but based on the info you provided, I think it is worth a shot considering the possibility of some code trying to use the counters when the add domain is about to be recycled. Look for the use of the counter in anything related to dispose or destructor.</p>
44,740
<p>I've been looking for some good genetic programming examples for C#. Anyone knows of good online/book resources? Wonder if there is a C# library out there for Evolutionary/Genetic programming?</p>
<p>After developing <a href="http://code.google.com/p/evo-lisa-clone/" rel="noreferrer">my own Genetic Programming didactic application</a>, I found a complete Genetic Programming Framework called <a href="http://code.google.com/p/aforge/source/browse/#svn/trunk/Sources/Genetic" rel="noreferrer">AForge.NET Genetics</a>...
<p>I maintain a port of ECJ in C#. It's great.</p>
3,488
<p>What's the shortest way to get an Iterator over a range of Integers in Java? In other words, implement the following:</p> <pre><code>/** * Returns an Iterator over the integers from first to first+count. */ Iterator&lt;Integer&gt; iterator(Integer first, Integer count); </code></pre> <p>Something like</p> <pre><...
<p>This implementation does not have a memory footprint.</p> <pre><code>/** * @param begin inclusive * @param end exclusive * @return list of integers from begin to end */ public static List&lt;Integer&gt; range(final int begin, final int end) { return new AbstractList&lt;Integer&gt;() { @Override ...
<p>It's generally considered good style to pass around <code>Collection</code> and friends instead of <code>Iterator</code> (see <a href="http://java.sun.com/j2se/1.4.2/docs/guide/collections/designfaq.html#8" rel="nofollow noreferrer">this FAQ entry</a>), so I'd recommend something like</p> <pre><code>public final cl...
48,485
<p>Sorry for the basic question - I'm a .NET developer and don't have much experience with LAMP setups.</p> <p>I have a PHP site that will allow uploads to a specific folder. I have been told that this folder needs to be owned by the webserver user for the upload process to work, so I created the folder and then set p...
<p>You can create a new group with both the apache user and FTP user as members and then make the permission on the upload folder 775. This should give both the apache and FTP users the ability to write to the files in the folder but keep everyone else from modifying them.</p>
<p>Based on the answer from <code>@Ryan Ahearn</code>, following is what I did on <code>Ubuntu</code> 16.04 to create a user <code>front</code> that only has permission for nginx's web dir <code>/var/www/html</code>.</p> <p><strong>Steps:</strong></p> <pre> * pre-steps: * basic prepare of server, * create use...
3,219
<p>I'm implementing a document server. Currently, if two users open the same document, then modify it and save the changes, the document's state will be undefined (either the first user's changes are saved permanently, or the second's). This is entirely unsatisfactory. I considered two possibilities to solve this probl...
<p>My suggestion would be something like your first one. When the first user (Bob) opens the document, he acquires a lock so that other users can only read the current document. If the user saves the document while he is using it, he keeps the lock. Only when he exits the document, it is unlocked and other people can e...
<p>Currently documents are published by a limited group of people, each of them working on a separate subject. So, the inconvenience introduced by locks is minimized. People mostly extend existing documents and correct mistakes in them.</p> <p>Speaking about the pessimistic model, the 'left client connected for N days...
3,107
<p>I can find tutorials about mapping textures to polygons specifying vertices etc. but nothing regarding how to apply a texture to a cube (or other stuff) drawn with glut (glutSolidCube).</p> <p>I am doing something like:</p> <pre><code>glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal); glTexParameterfv(GL_TEXT...
<p>No, since <code>glutSolidCube()</code> does not generate texture coordinates. Fortunately, though, <code>glutSolidCube()</code> is easy to implement yourself and add texture coordinates. Here's the source code to <code>glutSolidCube()</code> and associated functions, from <a href="http://www.opengl.org/resources/l...
<p>In case you want to avoid <code>glBegin\End</code> and <code>GL_TEXTURE_GEN_S\T</code> per modern design</p> <pre><code> void drawBox() { static glm::vec3 n[6] = { {-1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, {0.0, 0.0, 1.0...
42,371
<p>I guess it should be a common technique, However, I tried the following two options:</p> <p>1) Using my existing POP3 PHP client to access my local mail account. I am getting a "could not connect". Same code works if I run it with my localhost connecting to GoDaddy's pop3 server</p> <p>2) Parsing the local mbox fi...
<p>I'd go with the POP3 option. It should work once you get the right port/host etc.</p> <p>The other option will result in you duplicating a large part of the functionality already in the mail server, and its quite likely you'll have minor bugs in it resulting in emails not displaying properly, or worse, corruption i...
<p>Zend Framework has <a href="http://framework.zend.com/manual/en/zend.mail.read.html" rel="nofollow noreferrer">a mail component</a>, that allows you to read from various sources.</p>
42,580
<p>Given two colors and <em>n</em> steps, how can one calculate n colors including the two given colors that create a fade effect? </p> <p>If possible pseudo-code is preferred but this will probably be implemented in Java.</p> <p>Thanks!</p>
<p>Divide each colour into its RGB components and then calculate the individual steps required.</p> <pre><code>oldRed = 120; newRed = 200; steps = 10; redStepAmount = (newRed - oldRed) / steps; currentRed = oldRed; for (i = 0; i &lt; steps; i++) { currentRed += redStepAmount; } </code></pre> <p>Obviously extend t...
<p>How about <a href="https://stackoverflow.com/q/15757872/2012219">this answer</a></p> <pre><code>- (UIColor *)colorFromColor:(UIColor *)fromColor toColor:(UIColor *)toColor percent:(float)percent { float dec = percent / 100.f; CGFloat fRed, fBlue, fGreen, fAlpha; CGFloat tRed, tBlue, tGreen, tAlpha; ...
41,326
<p>So I have this regex:</p> <pre><code>(^(\s+)?(?P&lt;NAME&gt;(\w)(\d{7}))((01f\.foo)|(\.bar|\.goo\.moo\.roo))$|(^(\s+)?(?P&lt;NAME2&gt;R1_\d{6}_\d{6}_)((01f\.foo)|(\.bar|\.goo\.moo\.roo))$)) </code></pre> <p>Now if I try and do a match against this:</p> <pre> B048661501f.foo </pre> <p>I get this error:</p> <pre>...
<p>No, you can't have two groups of the same name, this would somehow defy the purpose, wouldn't it?</p> <p>What you probably <em>really</em> want is this:</p> <pre><code>^\s*(?P&lt;NAME&gt;\w\d{7}|R1_(?:\d{6}_){2})(01f\.foo|\.(?:bar|goo|moo|roo))$ </code></pre> <p>I refactored your regex as far as possible. I made ...
<p>As mentioned <a href="https://stackoverflow.com/a/44463324/416988">here</a>, Python PyPi <code>regex</code> module supports a <em>branch reset feature</em>.</p>
47,411
<p>According to the <a href="http://feedparser.org/docs/introduction.html" rel="noreferrer">feedparser documentation</a>, I can turn an RSS feed into a parsed object like this:</p> <pre><code>import feedparser d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml') </code></pre> <p>but I can't find any...
<p>Appended is a not hugely-elegant, but working solution - it uses feedparser to parse the feed, you can then modify the entries, and it passes the data to PyRSS2Gen. It preserves <em>most</em> of the feed info (the important bits anyway, there are somethings that will need extra conversion, the parsed_feed['feed']['i...
<pre><code>from xml.dom import minidom doc= minidom.parse('./your/file.xml') print doc.toxml() </code></pre> <p>The only problem is that it do not download feeds from the internet.</p>
21,956
<p>I want to take the url: <a href="http://www.mydomain.com/signup-12345" rel="nofollow noreferrer">http://www.mydomain.com/signup-12345</a></p> <p>And actually give them: <a href="http://www.mydomain.com/signup/?aff=12345" rel="nofollow noreferrer">http://www.mydomain.com/signup/?aff=12345</a></p> <p>I have NO histo...
<p>Try this : </p> <p>RewriteRule ^/signup-(\d+)/$ /signup/?aff=$1 [I]</p>
<p>As far i know, </p> <p><em>flag causes the RewriteCond to be ignored.</em> - for "Ignore case" - from <code>IsapiRewrite</code> version 2</p>
13,082
<h3>Summary</h3> <p>What's the best way to ensure a table cell cannot be less than a certain minimum width. </p> <h3>Example</h3> <p>I want to ensure that all cells in a table are at least 100px wide regards of the width of the tables container. If there is more available space the table cells should fill that space...
<p>This CSS should suffice:</p> <pre><code>td { min-width: 100px; } </code></pre> <p>However, it's not always obeyed correctly (the min-width attribute) by all browsers (for example, IE6 dislikes it a great deal).</p> <p><strong>Edit:</strong> As for an IE6 (and before) solution, there isn't one that works reliably ...
<p>IE6 handles width as min-width:</p> <pre><code>td { min-width: 100px; _width: 100px;/* IE6 hack */ } </code></pre> <p>If you want IE6 to handle width like normal browsers, give it an overflow:visible; (not the case here)</p>
8,067
<p>Can any one give me a scripts (HTML/CSS/Javascript) that can reproduce this error on <code>IE 7.0</code>? I am trying to fix this bug in my page where I get this warning but could not exactly found the problem. Line number does not match with the source either. </p> <p>I thought the better approach would be to crea...
<p>As Shog said, that error will occur when you try to call a method on an object which doesn't have that method.</p> <p>This is most often caused by an object being null when you expect it to, well, not be null.</p> <pre><code>var myEl = document.getElementById('myElement'); myEl.appendChild(...) </code></pre> <p>T...
<p>For IE, download the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2f465be0-94fd-4569-b3c4-dffdf19ccd99&amp;displaylang=en" rel="nofollow noreferrer">Microsoft Script Debugger</a></p>
39,533
<p>I'm writing a Java game and I want to implement a power meter for how hard you are going to shoot something. </p> <p>I need to write a function that takes a int between 0 - 100, and based on how high that number is, it will return a color between Green (0 on the power scale) and Red (100 on the power scale).</p> ...
<p>This should work - just linearly scale the red and green values. Assuming your max red/green/blue value is <code>255</code>, and <code>n</code> is in range <code>0 .. 100</code></p> <pre><code>R = (255 * n) / 100 G = (255 * (100 - n)) / 100 B = 0 </code></pre> <p><em>(Amended for integer maths, tip of the hat to ...
<p>Self contained example</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; //-------------------------------------------------------------------------- function gradient(left, mid, right) { var obj = {} var lt50 = {"r":(mid.r-left.r)/50.0, "g":(mid.g-left.g)/50.0, "b":(m...
44,192
<p>I am currently using Linq to NHibernate (although that is not an issue with regards to this question) to execute queries against my database and I want to be able to test whether the current <code>IQueryable</code> result instance has been executed or not.</p> <p>The debugger knows that my <code>IQueryable</code> h...
<p>How about writing an IQueryable wrapper like this:</p> <pre><code>class QueryableWrapper&lt;T&gt; : IQueryable&lt;T&gt; { private IQueryable&lt;T&gt; _InnerQueryable; private bool _HasExecuted; public QueryableWrapper(IQueryable&lt;T&gt; innerQueryable) { _InnerQueryable = innerQueryable; ...
<p>I believe you can use <a href="https://learn.microsoft.com/en-us/dotnet/api/system.data.linq.datacontext.log" rel="nofollow noreferrer">DataContext.Log</a> to log everything that is executed.</p>
7,966
<p>How do you perform the equivalent of Oracle's <code>DESCRIBE TABLE</code> in PostgreSQL (using the psql command)?</p>
<p>Try this (in the <code>psql</code> command-line tool):</p> <pre><code>\d+ tablename </code></pre> <p>See <a href="http://www.postgresql.org/docs/current/interactive/app-psql.html#APP-PSQL-META-COMMANDS" rel="noreferrer">the manual</a> for more info.</p>
<p>I worked out the following script for get table schema.</p> <pre><code>'CREATE TABLE ' || 'yourschema.yourtable' || E'\n(\n' || array_to_string( array_agg( ' ' || column_expr ) , E',\n' ) || E'\n);\n' from ( SELECT ' ' || column_name || ' ' || data_type || coalesce('(' || character_maximum_length || ')', '')...
13,463
<p>Hmm. I'm trying to deploy a web service to a new server and there is no ASP.NET tab. I've tried running <code>aspnet_regiis</code> from ASP.NET 2.0 directory but this doesn't seem to work. Any ideas anyone?</p>
<p>If you've had (or have...) VMware Server installed on this particular machine, the following steps will most likely fix the issue with minimal pain:</p> <ol> <li>Stop the IISAdmin service (and its dependencies)</li> <li>Open <code>%windir%\system32\inetsrv\MetaBase.xml</code> in a text editor</li> <li>Delete the li...
<p>reinstall IIS</p>
27,451
<p>Some files are uploaded with a reported MIME type:</p> <pre><code>image/x-citrix-pjpeg </code></pre> <p>They are valid jpeg files and I accept them as such.</p> <p>I was wondering however: why is the MIME type different?<br> Is there any difference in the format? or was this mimetype invented by some light bulb a...
<p><strong>Update:</strong><br> Ok, I did some more searching and testing on this question, and it turns out they're all lying about MIME-type (never trust <em>any</em> info send by the client, I know).<br> I've checked a bunch of files with different encodings (created with libjpeg)</p> <p><code>Official</code> MIME ...
<p>From what I recall the Progressive JPG format is the one that would allow the image to be shown with progressively higher resolution as the download of the file progressed. I am not entirely aware of the details, but if you remember back in the days of dial up, some files would show blurry, then better and eventuall...
24,525
<p>I'm on a team that uses scrum for our development process. We are currently trying to revamp certain aspects of our process to address some of the problems we've noticed lately. In doing so, we are exploring what it is that we like about the scrum process in general as well as what we don't like in order to help u...
<p>I don't like when managers implement scrum process as just quick release cycle, with all other aspects the same or worse as waterfall.</p>
<p>This is a pretty broad question! Here's my take.</p> <p>I think what Scrum is really good at is teaching organizations to love agile / iterative / incremental / lean software development. For a company that's used to a command and control hierarchy of project management, the empowerment necessary for teams to succe...
39,356
<pre><code>Pattern pattern = Pattern.compile("^[a-z]+$"); String string = "abc-def"; assertTrue( pattern.matcher(string).matches() ); // obviously fails </code></pre> <p>Is it possible to have the character class match a "-" ?</p>
<p>Don't put the minus sign between characters.</p> <pre><code>"[a-z-]" </code></pre>
<p>This works for me</p> <pre><code> Pattern p = Pattern.compile("^[a-z\\-]+$"); String line = "abc-def"; Matcher matcher = p.matcher(line); System.out.println(matcher.matches()); // true </code></pre>
18,610
<p>We have a WinForms application written in C# that uses the AxAcroPDFLib.AxAcroPDF component to load and print a PDF file. Has been working without any problems in Windows XP. I have moved my development environment to Vista 64 bit and now the application will not run (on Vista 64) unless I remove the AxAcroPDF compo...
<p>You can't convert Adobe's ActiveX control to 64bit yourself, but you can force your application to run in 32bit mode by setting the platform target to x86.</p> <p>For instructions for your version of Visual Studio, see section 1.44 of <a href="http://msdn.microsoft.com/en-gb/vstudio/aa718685.aspx" rel="noreferrer">...
<p>Use DLL isolation, works with every 32bit COM+ application. See more at: <a href="http://support.microsoft.com/kb/281335" rel="nofollow noreferrer">http://support.microsoft.com/kb/281335</a></p> <p>With this solution you can isolate your 32 bit COM+ application into a separate 32bit process.</p> <p>64bit applicati...
9,275
<p>Normally, the method of passing workflow parameters to the workflow happens in the call to RunWorkflow. However, with the WorkflowServiceHost, there is no such method call involved. You simply call the Open() method on the instance. Any ideas?</p> <p>Of course, the implication is that I add more parameters to th...
<p>Here is my complete code. I hope this will help.</p> <p>The xaml code:</p> <pre><code>&lt;Window x:Class="DataGridSort.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dg="clr-namespace:Microsoft.Windows.Controls;ass...
<p>If you build your class with INotifyPropertyChanged like this:</p> <pre><code>public class MyDataObject : INotifyPropertyChanged { private DateTime _SelectedDate; public DateTime SelectedDate { get { return _SelectedDate; } set { _SelectedD...
37,998
<p>Any suggestions on how to write repeatable unit tests for code that may be susceptible to deadlocks and race conditions?</p> <p>Right now I'm leaning towards skipping unit tests and focusing on stress tests. The problem with that is you can run a stress test 5 times and see five different results.</p> <p>EDIT: I k...
<p>Take a look at <a href="http://www.typemock.com/typemock-racer-product/" rel="nofollow noreferrer">TypeMock</a> Racer (it's in Beta)</p> <p>edit: actually Alpha</p> <p><a href="http://www.typemock.com/Typemock_software_development_tools.html" rel="nofollow noreferrer">http://www.typemock.com/Typemock_software_deve...
<p>I have previously used artificial delays in the code that are triggered by some parameters in the request. For example one request tells the server to delay write between two writes and another to do them with no delay in between. </p> <p>A Mark Bessey writes, this is only useful for creating repro, not for discove...
21,276
<p>I am working with a larger than average sqlite database (for use on both on windows and linux) and am looking to maximize the performance I get out of it. The database is to be installed on commodity hardware along with an sqlite gui. The users I am delivering this to are sql savvy but are unlikely to undertake thei...
<p>Have you read the <a href="http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html" rel="nofollow noreferrer">SQLite Optimization FAQ</a> (a few years old, but still seems useful)?</p> <p>I don't think 1gb is particularly large, even for SQLite. It can certainly handle much larger databases stably.</p>
<p>You should have a look at "scheduled tasks" and a script to "optimize tables" every night, perhaps even re-recreate your indexes. Doing so on a regular basis can save you a ton of time and manual labour.</p>
27,792
<p>I wish to send a header to my Apache server on a Linux box. How can I achieve this via a cURL call?</p>
<p><a href="https://curl.haxx.se/docs/manpage.html" rel="noreferrer"><code>man curl</code></a>:</p> <pre><code> -H/--header &lt;header&gt; (HTTP) Extra header to use when getting a web page. You may specify any number of extra headers. Note that if you should add a custom header that...
<p>Here are the some curl commands for most common http methods.</p> <p>Domain Object considered here is</p> <pre><code>@Data @NoArgsConstructor @AllArgsConstructor @Document @Validated public class Movie { @Id private String id; private String name; @NotNull private Integer year; @NotNull p...
46,512
<p>I'm wondering if there are any applications, preferably freeware, that can take a database configuration, and, with as little hassle as possible, create web forms for inserting data easily. </p> <p>I'm finding it hard to express exactly what it is I'm after. Maybe I can talk a bit about what I need.</p> <p>I have ...
<p>As many have already stated, it depends on what technology you're working with:</p> <ul> <li>.Net 3.5 - Dynamic Data or Subsonic's Scaffolding control</li> <li>.Net 2.0 - Subsonic's Scaffolding control </li> <li>PHP - CakePHP </li> <li>Ruby - Rail's Scaffolding component</li> </ul>
<p>You can try <a href="http://www.adminer.org/en/editor/" rel="nofollow">Adminer Editor</a></p> <blockquote> <p>Adminer Editor is both easy-to-use and user-friendly database editing tool written in PHP. It is suitable for common users, as it provides high-level data manipulation.</p> </blockquote>
41,015
<p>I have no experience with web services. Historically I've built client-server systems using proprietary communication protocols (even they happen to be XML). I just spent a few hours looking over Axis2 and it sent a shudder down my spine. The learning curve of WS scares me, and seeing all that XML surround so little...
<p>Build RESTful web APIs; then you get a lot of automatic caching and etc benefits that you don't get if you use other methods (SOAP, XML-RPC, etc)</p> <p>See <a href="https://stackoverflow.com/questions/106546/performance-of-soap-vs-xml-rpc-or-rest#106701">this post</a> for more details</p> <p>Another benefit is th...
<p>I have recently broken my custom protocol habit. I am now using Apache on the server side and libCurl plus libxml2 to load and parse the XML on the client which is written in C++.</p> <p>The server side can be either PHP or a CGI written in a more serious language. Depends what you want to do.</p>
15,167
<p>I am setting up Apache server with TortoiseSVN for a local source code repository. I have observed that if someone deletes a file using TortoiseSVN it will get deleted from everyone's view and the only log will be their in log history. I feel it is dangerous that any user can delete a file if they have read/write r...
<p>One of the beauties of source control is that it doesn't matter if someone deletes a file. If they delete a file and check it in and it should not have been deleted, just revert their revision. Simple as that.</p>
<p>I would recommend that you read a book about version control, preferably the <a href="http://svnbook.red-bean.com/" rel="nofollow noreferrer" title="Version Control with Subversion">Version Control with Subversion</a>. What you describe is not a problem, this is how version control works.</p>
14,269
<p>I need to match something in the form </p> <pre><code>&lt;a href="pic/5" id="piclink"&gt;&lt;img src="thumb/5" /&gt;&lt;/a&gt; </code></pre> <p>to find the number, in this case 5, using JavaScript. I have no idea how to use regexes, so I was wondering if anyone here could help out.</p>
<p>Just to make sure you know what's going on, the pattern you posted in your own answer will match exactly <strong>one</strong> digit between 0 and 9.</p> <p>If you want to match integers with one or more digits, you might try the pattern</p> <pre><code>/[0-9]+/ </code></pre> <p>Check out <a href="http://en.wikiped...
<p>Nevermind, I solved it with a simple </p> <pre><code>'&lt;a href="pic/5" id="piclink"&gt;&lt;img src="thumb/5" /&gt;&lt;/a&gt;'.match(/[0-9]/); </code></pre>
23,898
<p>I have a MySQL query structured as follows:</p> <pre><code>SELECT time(c.start_time), time(c.end_time), time(c.end_time) - time(c.start_time) as 'opening_hours' FROM my_shop c; </code></pre> <p>The data in start and end time is 1970-01-01 07:00:00 and 1970-01-01 19:00:00 respectively.</p> <p>On my ...
<p>I'd do it this way:</p> <pre><code>SELECT TIME(c.start_time), TIME(c.end_time), EXTRACT(HOUR FROM TIMEDIFF(TIME(c.end_time), TIME(c.start_time))) AS 'opening_hours' FROM my_shop c; </code></pre>
<p>Is there a better solution than this:</p> <pre><code>SELECT EXTRACT(HOUR FROM TIMEDIFF(TIME(c.end_time), TIME(c.start_time))) + ((EXTRACT(MINUTE FROM TIMEDIFF(TIME(c.end_time), TIME(c.start_time))))/60) FROM my_shop c; </code></pre>
47,169
<p>Is there a way with SVN to check out from a remote repository to another remote location rather than my local file system? Something like:</p> <pre><code>svn co http://myrepository/svn/project ssh me@otherlocation.net:/var/www/project </code></pre>
<p>I think you could do:</p> <pre><code>ssh me@other.net 'svn co http://repository/svn/project /var/www/project' </code></pre> <p>This takes advantage of the fact that ssh lets you execute a command remotely.</p>
<p>You could use Subversion with <a href="http://fuse.sourceforge.net/sshfs.html" rel="nofollow noreferrer" title="SSHFS">SSHFS</a>.</p>
19,254
<p>Please don't answer the obvious, but what are the limit signs that tell us a problem should not be solved using regular expressions?</p> <p>For example: Why is a complete email validation too complex for a regular expression?</p>
<p>When you need to parse an expression that's not defined by a <a href="http://en.wikipedia.org/wiki/Regular_language" rel="noreferrer">regular language</a>.</p>
<p>My limit is a Regex pattern that's about 30-50 characters long (varying depending on how much is fixed text and how much is regex commands)</p>
28,535
<p>What's your opinion on whether one should write an application for a specific platform or use a cross platform approach and reach more potential clients?</p> <p>It would be a GUI based application and I'm thinking of using Java.</p> <p>Most of the applications that I've used built on Java don't run as smooth as th...
<p>I would use Qt and yes, definitely target Cross Platform...</p> <p>The major reason isn't in fact what you think it is (being cross platform by itself) but actually that by targeting multiple platforms your code by some freaking weird magical reasons tends to end up with far better code quality. I've seen this happ...
<p>Why don't you consider Web Application.</p> <p>You can build rich UI Web site running in browser which runs everywhere and all platforms, If you are familiar with Java, you can try GWT for the 'Weblication' Check out the <a href="http://gwt.google.com/samples/Showcase/Showcase.html" rel="nofollow noreferrer">demo ...
40,772
<p>Any time I try to publish my Portal project on a Websphere Portal 6.1 Server, I get the following error message:</p> <pre><code>Portal project publishing is not supported on WebSphere Portal v6.1 Server </code></pre> <p>Is that really true or have I done something wrong?</p> <p>I'm trying to deploy a portal proje...
<p>Not sure this will help, but:</p> <blockquote> <p>Limitation: Although the WebSphere Portal installer contains an advanced option to install an empty portal, Portal Designer relies on administration portlets for setting access control; therefore, publishing a portal project to an empty portal is not...
<p>It is possible to deploy such a project to a WebSphere Portal. I use v6.2 and deploy portlets, which are parts of a big Portal project, every day. I'm only a starter in such a stuff, but I can say that WebSphere is really buggy. You know, it is a big difference to run a deployed app "locally, in a workspace" or "on ...
18,331
<p>I am trying to use <code>ActiveRecord::Base.transaction</code>. I figured that rollback doesn't work by default using Rails 1.2.6 and mysql 5.0. Playing with it a little bit more I found out that <code>autocommit</code> is not set to 0 in mysql connection.</p> <p><strong>Questions:</strong></p> <p>1) How do I disa...
<p>If you have a mix of code that needs explicit transactions and code that can rely on autocommit, perhaps you shouldn't disable autocommit for all connections. You're on the right track wondering if this will impact other code. If you disable autocommit, but the other code doesn't know it has to commit to have its ...
<p>Not that I have any specifically not transactional code - it is mostly all ActiveRecord objects, I just want to have rollback behavior if one of my methods fails. </p> <p>I will explore more , you seem to be right - I can confirm your answer in mysql console. However in my Rails application I have to do connection....
44,776
<p>How would I set an image to come from a theme directory (my theme changes so I don't want to directly reference) I am sure this is possible but every example I find doesn't seem to work. They are usually along the lines of:</p> <p>asp:image ID="Image1" runat="server" ImageUrl="~/Web/Mode1.jpg" /</p> <p>where Web w...
<p>If you are wanting to reference an Image in your Theme folder, then I suggesting using a SkinId. Inside the skin file of each Theme Folder you would define something like this</p> <pre><code>&lt;asp:Image runat="server" SkinId="HomeImage" ImageUrl="Images/HomeImage.gif" /&gt; </code></pre> <p>When you go to use th...
<p>Not sure if I understood your question right, but if you have an image in a skin file, such as the following, it will come by default from the theme folder:</p> <pre><code>&lt;asp:Image runat="server" ImageUrl="filename.ext" /&gt; </code></pre> <p>If you want it to come from a subfolder Web of the theme folder, us...
24,463
<p>It seems</p> <pre><code>import Queue Queue.Queue().get(timeout=10) </code></pre> <p>is keyboard interruptible (ctrl-c) whereas</p> <pre><code>import Queue Queue.Queue().get() </code></pre> <p>is not. I could always create a loop;</p> <pre><code>import Queue q = Queue() while True: try: q.get(time...
<p><code>Queue</code> objects have this behavior because they lock using <code>Condition</code> objects form the <code>threading</code> module. So your solution is really the only way to go.</p> <p>However, if you really want a <code>Queue</code> method that does this, you can monkeypatch the <code>Queue</code> class...
<p>This may not apply to your use case at all. But I've successfully used this pattern in several cases: (sketchy and likely buggy, but you get the point).</p> <pre><code>STOP = object() def consumer(q): while True: x = q.get() if x is STOP: return consume(x) def main() q ...
26,152
<p>Ok - a bit of a mouthful. So the problem I have is this - I need to store a Date for expiry where <em>only</em> the date part is required and I don't want any timezone conversion. So for example if I have an expiry set to "08 March 2008" I want that value to be returned to any client - no matter what their timezone ...
<p>You could create a struct Date that provides access to the details you want/need, like:</p> <pre><code>public struct Date { public int Month; //or string instead of int public int Day; public int Year; } </code></pre> <p>This is lightweight, flexible and gives you full control.</p>
<p>You can send it as UTC Time</p> <p>dateTime1.ToUniversalTime()</p>
10,518
<p><strong>Update:</strong> This turned into a blog post, with updated links and code, over at my blog: <a href="https://egilhansen.com/2008/12/01/how-to-take-control-of-style-sheets-in-asp-net-themes-with-the-styleplaceholder-and-style-control/" rel="nofollow noreferrer">https://egilhansen.com/2008/12/01/how-to-take-c...
<p>Found the answer to my own question.</p> <p>The reason for the rendering errors I am getting in design mode, is an apparent bug in Visual Studio SP1, <a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361826" rel="nofollow noreferrer">which Microsoft has yet to fix</a>.</p> <p...
<p>Works very smoothly.</p> <p>For those like me that never remember syntax of &lt;% tags here's what you need to add to the top of the master page definition and the skin file to register the namespace.</p> <pre><code>&lt;%@ Register TagPrefix="ass" Namespace="Assimilated.WebControls.Stylesheet" %&gt; </code></pre> ...
42,596
<p>If you have a situation where you need to know where a boolean value wasn't set (for example if that unset value should inherit from a parent value) the Java boolean primitive (and the equivalent in other languages) is clearly not adequate.</p> <p>What's the best practice to achieve this? Define a new simple class...
<pre><code>Boolean a = true; Boolean b = false; Boolean c = null; </code></pre> <p>I would use that. It's the most straight-forward.</p> <p>Another way is to use an enumeration. Maybe that's even better and faster, since no boxing is required:</p> <pre><code>public enum ThreeState { TRUE, FALSE, TRALSE }...
<p>java.lang.Boolean does this for you. There are static constants Boolean.TRUE, Boolean.False. </p> <p>private Boolean myBoolean;</p> <p>should be all you need.Note that Boolean.TRUE will pass an equivalence test but is distinct from "true" (which gets autoboxed to TRUE). </p>
40,637
<p>Our application has a file format similar to the OpenDocument file format (see <a href="http://en.wikipedia.org/wiki/OpenDocument" rel="noreferrer">http://en.wikipedia.org/wiki/OpenDocument</a>) - i.e. zipped with a manifest file, a thumbnail image, etc.</p> <p>I notice that OpenOffice files have a preview image of...
<h2>Windows</h2> <p>What you need is an <a href="http://msdn.microsoft.com/en-us/library/bb776857(VS.85).aspx" rel="nofollow noreferrer">Icon Handler</a>, also known as a Thumbnail Handler. Here is an example written as an <a href="http://www.shellplus.com/examples/thumbnail-image-handler-example.html" rel="nofollow ...
<p>This is up to the operating system as far as I know, it will be based on the file extension. </p>
14,697
<p>What is the most efficient way to remove duplicate items from an array under the constraint that axillary memory usage must be to a minimum, preferably small enough to not even require any heap allocations? Sorting seems like the obvious choice, but this is clearly not asymptotically efficient. Is there a better a...
<p>I'll answer my own question since, after posting, I came up with a really clever algorithm to do this. It uses hashing, building something like a hash set in place. It's guaranteed to be O(1) in axillary space (the recursion is a tail call), and is typically O(N) time complexity. The algorithm is as follows:</p> ...
<p>If you sort the array, you will still need another pass to remove duplicates, so the complexity is O(N<em>N) in the worst case (assuming Quicksort), or O(N</em>sqrt(N)) using Shellsort.</p> <p>You can achieve O(N*N) by simply scanning the array for each element removing duplicates as you go.</p> <p>Here is an exa...
46,701
<p>I am trying to write out a png file from a java.awt.image.BufferedImage. Everything works fine but the resulting png is a 32-bit file.</p> <p>Is there a way to make the png file be 8-bit? The image is grayscale, but I do need transparency as this is an overlay image. I am using java 6, and I would prefer to retu...
<p>The build in imageio png writer will write 32bit png files on all the platforms I have used it on, no matter what the source image is. You should also be aware that many people have complained that the resulting compression is much lower than what is possible with the png format. There are several independent <a hre...
<p>Thanks for responding, I was going to try an <code>TYPE_BYTE_INDEXED</code> with an IndexColorModel and may still but if ImageIO writes out 32-bit regardless it appears that I may be wasting my time there. </p> <p>The image I am trying to write out can be very large (up to 8000x4000) but is just a simple mask for ...
33,410
<p>I am opening a XML file using .NET XmlReader and saving the file in another filename and it seems that the DOCTYPE declaration changes between the two files. While the newly saved file is still valid XML, I was wondering why it insisted on changing original tags.</p> <pre><code>Dim oXmlSettings As Xml.XmlReaderSett...
<p>There is a bug in System.Xml when you set XmlDocument.XmlResolver = null. The workaround is to create a custom XmlTextWriter:</p> <pre><code> private class NullSubsetXmlTextWriter : XmlTextWriter { public NullSubsetXmlTextWriter(String inputFileName, Encoding encoding) : base(inputFileNam...
<p>This is best solution for you:</p> <pre><code>writer.WriteDocType("Name", Nothing, "http://xml.cxml.org/schemas/cXML/1.2.033/Fulfill.dtd", Nothing) </code></pre> <p>If you use <code>Nothing</code> you will not get [] or "" etc</p>
36,082
<p>We have a case where clients seem to be eternally caching versions of applets. We're making use of the <code>&lt;param name="cache_version"&gt;</code> tag correctly within our <code>&lt;object&gt;</code> tag, or so we think. We went from a version string of <code>7.1.0.40</code> to <code>7.1.0.42</code> and this t...
<p>Unfortunately, different versions of the Java Plug-In have different caching behaviors. Setting your Cache-Control and Last-Modified HTTP headers is the ideal solution, but it only works under <a href="http://java.sun.com/javase/6/docs/technotes/guides/deployment/enhancements.html" rel="noreferrer">the most recent v...
<p>As per <a href="http://docs.oracle.com/javase/1.3/docs/guide/misc/appletcaching.html" rel="nofollow">this link</a> , same jar file should not be listed int "archive" and "cache_archive" params. In that case, the JAR file is cached using the native browser cache.</p>
9,241
<p>I want to create a Silverlight 2 control that has two content areas. A Title and a MainContent. So the control would be:</p> <pre><code>&lt;StackPanel&gt; &lt;TextBlock Text=" CONTENT1 "/&gt; &lt;Content with CONTENT2 "/&gt; &lt;/StackPanel&gt; </code></pre> <p>When I use the control I should just be able to use...
<p>You can do that easily with the <a href="http://msdn.microsoft.com/en-us/library/system.windows.markup.contentpropertyattribute.aspx" rel="nofollow noreferrer">ContentProperty</a> attribute.</p> <p>Then you can define your code behind as:</p> <pre><code>[ContentProperty("Child")] public partial class MyControl: Us...
<p>What you wanted is a Silverlight version of the WPF HeaderedContentControl You can find a try here. <a href="http://leeontech.wordpress.com/2008/03/11/headeredcontentcontrol-sample/" rel="nofollow noreferrer">http://leeontech.wordpress.com/2008/03/11/headeredcontentcontrol-sample/</a></p>
25,480
<p>I have a need to open a popup detail window from a gridview (VS 2005 / 2008). What I am trying to do is in the markup for my TemplateColumn have an asp:Button control, sort of like this:</p> <pre><code>&lt;asp:Button ID="btnShowDetails" runat="server" CausesValidation="false" CommandName="Details" Text="Order D...
<p>I believe the way to do it is</p> <blockquote> <pre><code>onClientClick=&lt;%# string.Format("window.open('PubsOrderDetails.aspx?OrderId={0}',scrollbars=yes,resizable=yes, width=350, height=550);", Eval("order_id")) %&gt; </code></pre> </blockquote>
<p>I like @<a href="https://stackoverflow.com/questions/102343/including-eval-bind-values-in-onclientclick-code#102373">AviewAnew</a>'s suggestion, though you can also just write that from the code-behind by wiring up and event to the grid views ItemDataBound event. You'd then use the FindControl method on the event a...
12,788
<p>I'm not quite sure if this is possible, or falls into the category of pivot tables, but I figured I'd go to the pros to see.</p> <p>I have three basic tables: Card, Property, and CardProperty. Since cards do not have the same properties, and often multiple values for the same property, I decided to use the union ta...
<p>Is this for SQL server?</p> <p>If yes then</p> <p><a href="http://wiki.lessthandot.com/index.php/Concatenate_Values_From_Multiple_Rows_Into_One_Column" rel="nofollow noreferrer">Concatenate Values From Multiple Rows Into One Column (2000)</a><br> <a href="http://wiki.lessthandot.com/index.php/Concatenate_Values_Fr...
<p>Don't collapse by concatenation for storage of related records in your database. Its not exactly best practices. </p> <p>What you're describing is a pivot table. Pivot tables are <em>hard</em>. I'd suggest avoiding them if at all possible. </p> <p>Why not just read in your related rows and process them in mem...
3,881
<p>I'm working on a free software (bsd license) project with others. We're searching for a system that check out our source code (svn) and build it also as test it (unit tests with Check / other tools).</p> <p>It should have a webbased interface and generate reports.</p> <p>I hope we don't have to write such a system...
<p>You surely do not have to code this yourself - there are a lot of <a href="http://en.wikipedia.org/wiki/Continuous_integration" rel="nofollow noreferrer">continuous integration</a> systems which are able to check out source code from systems such as SVN and they are generally easy to extend with your own tasks, so r...
<p>Check out <a href="http://buildbot.net/trac" rel="nofollow noreferrer">buildbot</a></p>
22,112
<p>Do you have any tricks for generating SQL statements, mainly INSERTs, in Excel for various data import scenarios?</p> <p>I'm really getting tired of writing formulas with like </p> <p><code>="INSERT INTO Table (ID, Name) VALUES (" &amp; C2 &amp; ", '" &amp; D2 &amp; "')"</code></p>
<p>The semi-colon needs to be inside the last double quote with a closing paren. When adding single quotes around a string, remember to add them outside your selected cell. </p> <p>(spaces added for visibility - remove before inserting)</p> <p><code>=CONCATENATE("insert into table (id, name) values (",C2,",' ",D2," ...
<p>I was doing this yesterday, and yes, it's annoying to get the quotes right. One thing I did was have a named cell that just contained a single quote. Type into A1 <code>="'"</code> (equals, double quote, single quote, double quote) and then name this cell "QUOTE" by typing that in the box on the left of the lowest...
40,728
<p>I have a JavaScript array that, among others, contains a URL. If I try to simply put the URL in the page (the array is in a project involving the Yahoo! Maps API) it shows the URL as it should be.</p> <p>But if I try to do a redirect or simply do an 'alert' on the link array element I get: </p> <blockquote> <p>f...
<pre><code>var obj = jQuery.parseJSON('{"name":"John"}'); alert( obj.name === "John" ); </code></pre> <p><a href="http://api.jquery.com/jQuery.parseJSON/" rel="noreferrer">See the jQuery API</a>.</p>
<p>I decode JSON this way:</p> <pre><code>eval( 'var from_json_object = ' + my_json_str + ';' ); </code></pre>
22,044
<p>For example:</p> <pre><code>&gt;&gt;&gt; x = [1, 1, 2, 'a', 'a', 3] &gt;&gt;&gt; unique(x) [1, 2, 'a', 3] </code></pre> <p>Assume list elements are hashable.</p> <p><strong>Clarification:</strong> The result should keep the first duplicate in the list. For example, [1, 2, 3, 2, 3, 1] becomes [1, 2, 3].</p>
<pre><code>def unique(items): found = set() keep = [] for item in items: if item not in found: found.add(item) keep.append(item) return keep print unique([1, 1, 2, 'a', 'a', 3]) </code></pre>
<p>I haven't done any tests, but one possible algorithm might be to create a second list, and iterate through the first list. If an item is not in the second list, add it to the second list.</p> <pre><code>x = [1, 1, 2, 'a', 'a', 3] y = [] for each in x: if each not in y: y.append(each) </code></pre>
11,474
<p>I can only think of Peek() and ReadNoAdvance() atm, but I wonder if there are better or standard options.</p> <p>Thanks.</p>
<p>peek is the standard name, present in various languages.</p>
<p>When writing parsers I've often also used <code>lookahead</code>.</p>
40,935
<p>Explain why a nullable int can't be assigned the value of null e.g</p> <pre><code>int? accom = (accomStr == "noval" ? null : Convert.ToInt32(accomStr)); </code></pre> <p>What's wrong with that code?</p>
<p>The problem isn't that null cannot be assigned to an int?. The problem is that both values returned by the ternary operator must be the same type, or one must be implicitly convertible to the other. In this case, null cannot be implicitly converted to int nor vice-versus, so an explict cast is necessary. Try this in...
<p>Similarly I did for long:</p> <pre><code>myLongVariable = (!string.IsNullOrEmpty(cbLong.SelectedItem.Value)) ? Convert.ToInt64(cbLong.SelectedItem.Value) : (long?)null; </code></pre>
42,809
<p>What is the maximum size for a MySQL table? Is it 2 million at 50GB? 5 million at 80GB?</p> <p>At the higher end of the size scale, do I need to think about compressing the data? Or perhaps splitting the table if it grew too big?</p>
<p>I once worked with a very large (Terabyte+) MySQL database. The largest table we had was literally over a billion rows. </p> <p>It worked. MySQL processed the data correctly most of the time. It was extremely unwieldy though. </p> <p>Just backing up and storing the data was a challenge. It would take days to resto...
<p>About your first question, the effective maximum size for the <em>database</em> is usually determined by operating system, specifically the file size MySQL Server will be able to create, not by MySQL Server itself. Those limits play a big role in <em>table</em> size limits. And MyISAM works differently from InnoDB. ...
7,110
<p>Char's are great because they are fixed size and thus make for a faster table. They are however limited to 255 characters. I want to hold 500 characters but a blob is variable length and that's not what I want.</p> <p>Is there some way to have a fixed length field of 500 characters in MySQL or am I going to have to...
<p>I would suggest using a varchar(500). Even though varchar isn't a fixed length, the database should reserve the correct amount of space. You shouldn't notice any performance difference using varchar(500) over 2xchar(255).</p> <p>You're also probably going to cause extra overhead by joining two char fields together....
<p>You're worrying too much about internal implementation details. Don't pre-optimize. </p> <p>Go with <code>VARCHAR(500)</code></p>
2,705
<p>I've have searched on this and it seems to be a catch all, unfortunately everything I've read doesn't help figure it out. Here is the class:</p> <pre><code>public interface IMockInterface { MockClass MockedMethod(); MockClass MockThis(); } public class MockClass : IMockInterface { public virtual MockCla...
<p>You're telling the mock framework to stub the MockedMethod class on the provider object, but you never inject the provider into the mainClass object to be used. It's not clear to me what you are trying to accomplish but if you want the mocked method to be called then it has to be called on the object on which the s...
<p>I usually get this error when a stubbed method is called with an object argument that I build in the test and in the tested code the object is built before calling that method. The solution is to use the <code>Rhino.Mocks Matches()</code>. </p> <p>Ex: </p> <pre><code>Arg&lt;string&gt;.Matches(s =&gt; s.Contains("s...
48,298
<p>I have a table which has roughly 10 cells, 4 different types. I subclassed UITextViewCell because I wanted to have an IBOutlet to a label and to a UITextField. Not sure if that was the best way of handling it, but it works thus far. Next, I had a cell for gender, so I figured instead of subclassing UITableViewCell, ...
<p>I'd actually go for subclassing. Subclassing is cheap. The cells have different types, and what you're doing now is iterating through all the subviews and checking each view for membership of a class - this is slow! A subclass will clean up your code and make it faster at the same time. Don't try to shoe-horn to...
<p>You could always just add the control to your subclass but have it hidden. Then, depending on the row, set the cell's "mode". The mode setter can hide / unhide the controls that pertain to that row. If performance is an issue, maybe use multiple cell IDs so that the views are cached.</p>
44,510
<p>I need to support exact phrases (enclosed in quotes) in an otherwise space-separated list of terms. Thus splitting the respective string by the space-character is not sufficient anymore.</p> <p>Example:</p> <pre><code>input : 'foo bar "lorem ipsum" baz' output: ['foo', 'bar', 'lorem ipsum', 'baz'] </code></pre> <...
<pre><code>var str = 'foo bar "lorem ipsum" baz'; var results = str.match(/("[^"]+"|[^"\s]+)/g); </code></pre> <p>... returns the array you're looking for.<br> Note, however:</p> <ul> <li>Bounding quotes are included, so can be removed with <code>replace(/^"([^"]+)"$/,"$1")</code> on the results.</li> <li>Spaces be...
<p>One that's easy to understand and a general solution. Works for all delimiters and 'join' characters. Also supports 'joined' words that are more than two words in length.... ie lists like </p> <p><code>"hello my name is 'jon delaware smith fred' I have a 'long name'"</code>....</p> <p>A bit like the answer by AC b...
9,057
<p>It could be part of the model because it's part of the business logic of the game.</p> <p>It could be part of the controller because it could be seen as simulating player input, which would be considered part of the controller, right? Or would it?</p> <p>What about a normal enemy, like a goomba in Mario?</p> <p>U...
<p>Remember that MVC was originally purely a GUI architectural pattern. So it is of no surprise that it doesn't map well to AI, networking, or whatever. But there are still some benefits to using it here. But what the code achieves is not as important as where it sits in the chain. Just because something looks like it'...
<p>Neither. I would program an AI as an independant agent communicating with the model via the controller. Or if you like, the AI is <em>A</em> model, but not <em>the</em> model.</p>
46,523
<p>Bascially I want to know the best way to hide/show an ASP.NET control from a Javascript function. I figured I would just access the control in Javascript using:</p> <pre><code>var theControl = document.getElementById("txtEditBox"); </code></pre> <p>Then just set the control's Visible property to true/false. It d...
<p>The "Visible" property of an ASP.NET control determines whether or not it will be rendered on the client (i.e. sent to the client). If it is false when the page is rendered, it will never arrive at the client.</p> <p>So, you cannot, technically, set that property of the control.</p> <p>That said, if the control <e...
<p>I think the best solution is to put your ASP control inside a div and set the property display to the div element.</p> <pre><code>&lt;div id="divTest"&gt; &lt;asp:TextBox ID="txtTest" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; SIN JQuery documen...
33,508
<p>Deep down in WinDef.h there's this relic from the segmented memory era:</p> <pre><code>#define far #define near </code></pre> <p>This obviously causes problems if you attempt to use near or far as variable names. Any clean workarounds? Other then renaming my variables?</p>
<p>You can safely undefine them, contrary to claims from others. The reason is that they're just macros's. They only affect the preprocessor between their definition and their undefinition. In your case, that will be from early in windows.h to the last line of windows.h. If you need extra windows headers, you'd include...
<p>Best not to. They are defined for backwards compatibility with older code - if you got rid of them somehow and then later needed to use some of that old code you'd be broken.</p>
14,460
<p>I use an Ender 3, with cheap Amazon "Eryone PLA", which states a range from 190-220&nbsp;&deg;C, 1.75&nbsp;mm dia. I have had this for about a year.</p> <p>I use the rough build plate, not the glass. I have tried my best to level the bed but I am an amateur</p> <p>I was originally getting poor adhesion so I cleane...
<p>This is clearly overextrusion relative to the volume the material is being deposited into, but that doesn't necessarily mean your extrusion rate is wrong. It could be:</p> <ul> <li>Nozzle smashed down into the bed (bed way too high) but somehow still extruding</li> <li>Problem in Z axis movement preventing the head...
<p>Bad filament is my answer. I bought PRLine and both print terrible like your picture. Suspect 2 factors, one is that the line is less than 1.75, so they underextrude and so you see those lines and in some cases gaps, second is the material itself is slippery suggesting to me that it has florinated additives.</p>
1,621
<p>I got a web application, the problem is that the text in the label will not update on the first click, I need to click the button twice, I debugged to code, and I found out that the label does not recive the data until after the second click,</p> <p>Here is my code:</p> <pre><code>System.Data.SqlClient.SqlCommand ...
<p>To be very clear. The button click event happens after the Page_Load event meaning that the filtering does not get applied on the first postback. It has been updated on the second postback and you see the filtering. The simplest change to get your code to work is to move all the code in your Page_Load event into OnP...
<p>I was stuck on this for about a week. Finally, I've put the code behind for the <code>Button_Click</code> event in the <code>TextChanged</code> event and it worked. Pressing the button makes the focus leave the <code>TextBox</code> so that event fires when the <code>Button_click</code> event doesn't. Very kludgy. I ...
38,020
<p>I am very new to Java. My assignment is to create my own method and then create a class to test it in. My question, do I create the method separate of the class, or within the class? If it is separate of the class, how do I get the class to access my method?</p> <p>(Are they saved as two separate files?)</p> <p>Th...
<p>For a simple assignment such as this, you can probably create your method in the same class as your class. Create a class with a static main method, which will be your programs starting point, and then create your method which will be called.</p> <p>Seems like you are quite new to programming I would take advantag...
<p>OR you can create like follows</p> <pre><code>public class MyClass { public int myMethod() { ,,,,, } } public class myTest { public void testMyMethod() { MyClass testClass = new MyClass(); int output = testClass.myMethod(); . . } } </code></pre> <p>In Java, all methods need to be inside a cla...
28,242
<p>I'd like to write a Ruby snippet that gets run when my Gem is first installed via <code>[sudo ]gem install mygem</code>. Can it be done?</p>
<p>It doesn't look like it's really supported. I found a "post_install_message" attribute that you should be able to set in the gem spec, but that won't execute code.</p> <p>You may be able to do it by packaging your on-install code as an extension in your gem (as if it were a native extension), and providing a Rakefi...
<p>You can try to do this using call of OS commands. I'll quote eample from irb but you can do same in your scripts too.</p> <pre><code>irb(main):001:0&gt; system 'gem list | grep rails' rails (2.1.1, 2.1.0) =&gt; true irb(main):002:0&gt; system 'gem list | grep railssssss' =&gt; false </code></pre> <p>You can use re...
27,545
<p>I am displaying a scrolled data table in a web page. This table has several thousands of dynamic rows, so it is loaded from the server (via AJAX).</p> <p>The user can scroll up and down, so what I need is to <strong>detect when the user reaches the end of the scrollbar</strong> (that is, the last row at the bottom...
<p>Thank you for your answers. That's my final working code (inspired by Greg and <a href="http://ajaxian.com/archives/implementing-infinite-scrolling-with-jquery" rel="nofollow noreferrer">ajaxian.com</a>), that uses some jQuery functions and works with the <a href="http://developer.yahoo.com/yui/datatable/" rel="nof...
<p>There is a property I noticed while reading through DOM properties in Firebug today called <code>scrollY</code> (in Firebug under the DOM tab go to <code>content</code> > <code>scrollY</code>) which appears to be the amount of pixels left to scroll on the window. Try seeing if this is also created for scrollable ele...
26,625
<p>I need to simulate a low bandwidth, high latency connection to a server in order to emulate the conditions of a VPN at a remote site. The bandwidth and latency should be tweakable so I can discover the best combination in order to run our software package.</p>
<p>For <strong>macOS</strong>, there is the <em>Network Link Conditioner</em> that simulates configurable bandwidth, latency, and packet loss. It is contained in the <a href="https://developer.apple.com/download/more/?q=Additional%20Tools%20for%20Xcode" rel="nofollow noreferrer">Additional Tools for Xcode</a> package. ...
<p>LANforge ICE is a <a href="http://www.candelatech.com/emulate.php" rel="nofollow">network emulator</a> with an emphasis on virtual routing, jitter, corruption and delay. Projects have used it to emulate satellite link, cable and modem connections, and high-speed (10Gbit) wan emulation. You can use a Java GUI to bui...
15,831
<p>I need to implement a <a href="http://en.wikipedia.org/wiki/Wavetable" rel="nofollow noreferrer">wavetable synthesizer</a> in an ARM Cortex-M3 core. I'm looking for any code or tools to help me get started.</p> <p>I'm aware of <a href="http://elm-chan.org/works/mxb/report.html" rel="nofollow noreferrer">this AVR im...
<p>The Synthesis Toolkit (STK) is excellent, but it is C++ only:</p> <p><a href="http://ccrma.stanford.edu/software/stk/" rel="noreferrer">http://ccrma.stanford.edu/software/stk/</a></p> <p>You may be able to extract the wavetable synthesizer code from the STK though.</p>
<p>Any ARM synth, the best ones, can be changed to wavescanner in less than a day. Scanning the wave from files or generating them mathematically is nearly the same thing audio wise, WT provides massive banks of waveforms at zero processing cost, you need the waves, the WT oscillator code itself is 20 lines. so change ...
4,935
<p>I have a linq to sql database. Very simplified we have 3 tables, Projects and Users. There is a joining table called User_Projects which joins them together. </p> <p>I already have a working method of getting <code>IEnumberable&lt;Project&gt;</code> for a given user. </p> <pre><code>from up in User_Projects select...
<p>Linq to Sql doesn't understand how to work with an arbitrary in-memory sequence of objects. You need to express this in relational terms, which works on IDs:</p> <pre><code>var userProjectIds = from project in GetProjects() select project.ProjectId; var nonUserProjects = from project in db.Projects ...
<p>try this:</p> <pre><code>var userProjects = GetProjects(); return db.Projects.Except(userProjects.ToArray()); </code></pre> <p>The ToArray should force evaluation of the sequence (if I'm understanding the issue right) and allow the operation to succeed.</p>
42,928
<p>C#: How do you tell which item index is selected in ListView?</p>
<pre><code>ListView mylistv = new ListView(); var index = mylistv.SelectedIndices(); </code></pre> <p>That should do it.</p>
<p>Use the SelectedIndex property of the class.</p>
36,730
<p>How do I escape '&lt;' and '>' character in sed.</p> <p>I have some xml files which needs some text between the tags to be replaced. How do I escape the '>' and '&lt;' characters.</p> <p>The problem with > and &lt; is it has special meaning in the shell to redirect the output to a file. So backslash doesn't work.<...
<p>Ok. Found out by myself. Use quotes.</p> <pre><code>$ sed -i "s/&gt;foo&lt;/&gt;bar&lt;/g" file </code></pre>
<p>Escape them with backslash</p>
18,471
<p>What is the recommended way to embed PDF in HTML?</p> <ul> <li>iFrame? </li> <li>Object? </li> <li>Embed?</li> </ul> <p>What does Adobe say itself about it?</p> <p>In my case, the PDF is generated on the fly, so it can't be uploaded to a third-party solution prior to flushing it.</p>
<p>Probably the best approach is to use the <a href="https://mozilla.github.io/pdf.js/" rel="noreferrer">PDF.JS</a> library. It's a pure <a href="https://en.wikipedia.org/wiki/HTML5" rel="noreferrer">HTML5</a>/<a href="https://en.wikipedia.org/wiki/JavaScript" rel="noreferrer">JavaScript</a> renderer for PDF documents ...
<p>If you don't want to host PDF.JS on your own, you could try <a href="https://www.docdroid.net" rel="nofollow noreferrer">DocDroid</a>. It is similar to the Google Drive PDF viewer but allows custom branding. </p>
37,220