instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Is there any conflict?</p>
| <p>All new versions of Delphi can always be installed safely /next/ to older version.</p>
<p>Each new version should be installed in its own directory.</p>
<p>If you are going to install multiple versions, always install the oldest version first, and then work your way to the newest. </p>
<p>We work very hard to ma... | <p>CodeGear stated (don't have a link handy, sorry) that there should be no conflict. I haven't yet installed D2009 on my workhorse PC so I don't know if that is correct.</p>
<p>The settings in registry have different path and packages have different names so there really should be no problems.</p>
| 16,916 |
<p>I do not have problem as such but I am quite new to Ruby. I have the following 3 repeatable bits of code in one method and I would like to know how a true Rubyist would first of all remove the duplication and secondly make it more reusable.</p>
<p>Here is the code in question:</p>
<pre><code>file = File.new( dest... | <p>The last two blocks could be replaced with</p>
<pre><code>["add", "connectionStrings/plans"].each do |elt_name|
doc.elements.each("configuration/#{elt_name}").do |elt|
elt.raw_attributes = elt.attributes.merge("connectionString" => "#{TEST_CONNECTION_STRING}")
end
end
</code></pre>
<p>I assume the case ... | <p>You could try to add a method that tries to be as generic as possible to avoid this, but they are significantly different for me... You risk having complex code just to be able to wrap these lines into a single method.</p>
| 49,847 |
<p>I have the following Int lists:</p>
<pre><code>t1 = [1000, 1001, 1002, 1003, 1004]
t2 = [2000, 2001, 2002]
t3 = [3000, 3001, 3002, 3003]
</code></pre>
<p>The lists size are variable, they are not just 3 like in this example. They can have 1 element or many more. Then I have this:</p>
<pre><code>tAll = [t1, t2, t3... | <p>Well, this is the Haskell beginner's way to write it, but since it's doing explicit recursion there is probably a better way. :-)</p>
<pre><code>head0 [] = 0
head0 xs = head xs
tail0 [] = []
tail0 xs = tail xs
nreorder n ts
| all null ts = []
| otherwise = (n : map head0 ts) : nreorder (n+1) (map tail0 ts)
... | <p><code>zip3</code> will turn the 3 lists into a single list of triples. If you want length-three lists instead, you can use <code>zipWith3 (\a b c -> [a,b,c])</code></p>
<p>If you want something different in detail (as in your updated request), you'll have to roll your own. I'd say, put your termination conditio... | 49,645 |
<p>I always felt that expecting exceptions to be thrown on a regular basis and using them as flow logic was a bad thing. Exceptions feel like they should be, well, the "<em>exception</em>". If you're expecting and planning for an exception, that would seem to indicate that your code should be refactored, at least in ... | <p>Your lead is absolutely right. Exceptions are not just for once in a blue moon situations, but specifically for reporting other than expected outcomes.</p>
<p>In this case the foreign key check would still take place, and exceptions are the mechanism by which you can be notified.</p>
<p>What you should NOT do is c... | <p>Catching the specific SqlException is the right thing to do. This is the mechanism by which SQL Server communicates the foreign key condition. Even if you might favor a different usage of the exception mechanism, this is how SQL Server does it.</p>
<p>Also, during your check on the four tables, some other user mi... | 16,309 |
<p>I've got an image library on Amazon S3. For each image, I md5 the source URL on my server plus a timestamp to get a unique filename. Since S3 can't have subdirectories, I need to store all of these images in a single flat folder.</p>
<p>Do I need to worry about collisions in the MD5 hash value that gets produced?</... | <p>Probability of just two hashes accidentally colliding is <strong>1/2<sup>128</sup></strong> <a href="http://www.wolframalpha.com/input/?i=2%5E128" rel="noreferrer">which is</a> 1 in 340 undecillion 282 decillion 366 nonillion 920 octillion 938 septillion 463 sextillion 463 quintillion 374 quadrillion 607 trillion 43... | <p>MD5 collision is extremely unlikely. If you have <strong>9 trillion</strong> MD5s, there is only one chance in <strong>9 trillion</strong> that there will be a collision.</p>
| 24,638 |
<p>Much searching has lead me to find several descriptions of how to create a bootstrapping msi, but these solutions all assume the msi is local or a standard Windows component. Is there a way to make an msi that downloads an installer (which is also an msi) with normal MSI or Wix code rather than by having the bootst... | <p>My experience with msi's has been it's not possible to run 2 at the same time. (could be wrong though)</p>
<p>What I ended up doing was to instead make an installer exe using Inno Setup (<a href="http://www.jrsoftware.org" rel="nofollow noreferrer">http://www.jrsoftware.org</a>) and ISTool (<a href="http://www.isto... | <p>Windows prevents two installs from being in the <code>InstallExecuteSequence</code> at the same time, so if you're looking for a silent install solution with a bootstrapper, you're SOL.</p>
<p>However you <em>can</em> start another install from the UI sequence, which is probably an OK solution as long as you advise... | 31,644 |
<p>When I try to precompile a *.pc file that contains a #warning directive I recieve the following error:</p>
<blockquote>
<p>PCC-S-02014, Encountered the symbol "warning" when expecting one of the following: (bla bla bla).</p>
</blockquote>
<p>Can I somehow convince Pro*C to ignore the thing if it doesn't know wha... | <p>According to the <em>Pro*C/C++ Programmer's Guide</em> (chapter 5 "Advanced Topics"), Pro*C silently ignores a number of preprocessor directives including #error and #pragma, but sadly not #warning. Since your warning directives are included in a header file, you might be able to use the ORA_PROC macro:</p>
<pre><... | <p>Remove below two lines from /usr/include/standards.h</p>
<h1>warning The -qdfp option is required to process DFP code in headers.</h1>
<h1>else</h1>
| 3,549 |
<p>I am receiving SOAP requests from a client that uses the Axis 1.4 libraries. The requests have the following form:</p>
<pre><code><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3... | <p>I have the same issue. For the moment, I've worked around it by writing a BasicHandler extension, and then walking the SOAPPart myself and moving the namespace reference up to a parent node. I don't <em>like</em> this solution, but it does seem to work.</p>
<p>I really hope somebody comes along and tells us what ... | <p>Alter your client's wsdd to set <code>enableNamespacePrefixOptimization</code> to <code>true</code></p>
<pre><code><globalConfiguration >
<parameter name="enableNamespacePrefixOptimization" value="true"/>
</code></pre>
| 8,791 |
<p>What is meant by ‘value semantics’, and what is meant by ‘implicit pointer semantics’?</p>
| <p>Java is using implicit pointer semantics for Object types and value semantics for primitives.</p>
<p>Value semantics means that you deal directly with values and that you pass copies around.
The point here is that when you have a value, you can trust it won't change behind your back.</p>
<p>With pointer semantics,... | <p>Java uses <code>implicit pointer semantics</code> on <em>variable access</em> (you can not directly edit the reference, it autmatically (implicit) gets resolved to the Object on access) and also uses <code>Pass-by-Value semantics</code> on <em>method parameters passing</em>. </p>
<p>Read <a href="http://web.archive... | 20,049 |
<p>Connection Code:</p>
<pre><code>set conx = Server.CreateObject("ADODB.connection")
conx.Open Application("connectionString")
set cmdx = server.CreateObject("ADODB.command")
cmdx.ActiveConnection = conx
cmdx.CommandText = "dbo.sproc"
cmdx.CommandType = &H0004
set rsx = Server.CreateObject("ADODB.Recordset")
rs... | <p>Just a punt here, but the way OLEDB drivers handle Row count informationals differs from ODBC.</p>
<p>I very much suspect that if you add SET NOCOUNT ON at the top of the Stored Procedure the problem will go away.</p>
| <p>Sounds like a permissions problem in the database!</p>
| 45,418 |
<p>Just looking at:</p>
<p><img src="https://i.stack.imgur.com/G0ifh.png" alt="XKCD Strip" title="Her daughter is named Help I'm trapped in a driver's license factory.">
<em>(Source: <a href="https://xkcd.com/327/" rel="noreferrer">https://xkcd.com/327/</a>)</em></p>
<p>What does this SQL do:</p>
<pre><code>... | <p><strong>It drops the students table.</strong></p>
<p>The original code in the school's program probably looks something like</p>
<pre><code>q = "INSERT INTO Students VALUES ('" + FNMName.Text + "', '" + LName.Text + "')";
</code></pre>
<p>This is the naive way to add text input into a query, and is <em>very bad</... | <p>This is how it works:
Lets suppose the administrator is looking for records of student </p>
<pre><code>Robert'); DROP TABLE STUDENTS; --
</code></pre>
<p>Since the admin account has high privileges deleting the table from this account is possible.</p>
<p>The code to retrieve user name from request is</p>
<p>Now... | 43,056 |
<p>I have several files containing this line</p>
<pre><code>Release: X
</code></pre>
<p>I want to increment X in all the files. </p>
<p>If X was constant between the files, I could have a bash script looping around the files and doing ($1 containing the former release number and $2 the new one, ie. $1 + 1) :</p>
<p... | <p>Use <code>awk</code> - it's exactly the right tool for this:</p>
<pre><code>awk '/Release: [0-9]+/ { printf "Release: %d\n", $2+1 }' < $file > $file.new
</code></pre>
<p>Translation:</p>
<ul>
<li>Search for lines that contain "Release: " followed by one or more digits.</li>
<li>Print "Release: " followed by... | <p>This perl one-liner will do the same as the awk script, but not destroy the rest of the file or the rest of the lines that contain the release.</p>
<pre><code> perl -pe "$_=~s/Release: (\d+)/'Release: '. ($1+1)/e;" < file > file.new
</code></pre>
| 48,967 |
<p>I am using a ASP/.Net webpage and i want to upload a pdf file into a SQL Database as a binary I am uping the build in upload control, can you please suggest a way of doing this. I also need to no how to read the pdf back and display it in a web browser. I will be using linq to upload and query my sql database.</p... | <p>You can use the <code>VARBINARY(MAX)</code> type in your database, create a LINQ to SQL mapping and use the <code>Binary</code> type with the <code>byte[]</code> type containing your PDF file's content.</p>
| <p>For displaying the PDF back to the user, with aspx, you need to use an HTTPHandler. You'll simply write the pdf's bytes out to the HTTP response, making sure to properly set the "content-type" header. Here's a forum discussion which describes the solution:</p>
<p><a href="http://forums.asp.net/p/1120590/1750793.asp... | 30,131 |
<p>I have a co-worker that maintains that TRUE used to be defined as 0 and all other values were FALSE. I could swear that every language I've worked with, if you could even get a value for a boolean, that the value for FALSE is 0. Did TRUE used to be 0? If so, when did we switch?</p>
| <p>The 0 / non-0 thing your coworker is confused about is probably referring to when people use numeric values as return value indicating success, not truth (i.e. in bash scripts and some styles of C/C++). </p>
<p>Using 0 = success allows for a much greater precision in specifying causes of failure (e.g. 1 = missing f... | <p>In any language I've ever worked in (going back to BASIC in the late 70s), false has been considered 0 and true has been non-zero.</p>
| 12,978 |
<p>I am trying to achieve better performance for my Java SWT application, and I just found out it is possible to use OpenGL in SWT. It seems there are more than one Java binding for OpenGL. Which one do you prefer?</p>
<p>Note that I have never used OpenGL before, and that the application needs to work on Windows, Lin... | <p><a href="http://www.opengl.org/resources/bindings/" rel="noreferrer" title="opengl.org">JOGL</a></p>
<p>My reasons can be quoted off the previously linked site:</p>
<blockquote>
<p>JOGL provides full access to the APIs in the OpenGL 2.0 specification as well as nearly all vendor extensions, and integrates with t... | <p>We've had lots of luck at work using JOGL. The new 2.0 version is at <a href="http://jogamp.org/" rel="nofollow">http://jogamp.org/</a> (the last "old" version is at <a href="http://download.java.net/media/jogl/builds/archive/jsr-231-1.1.1a/" rel="nofollow">http://download.java.net/media/jogl/builds/archive/jsr-231-... | 9,196 |
<p>What is the best way to shred XML data into various database columns? So far I have mainly been using the nodes and value functions like so:</p>
<pre><code>INSERT INTO some_table (column1, column2, column3)
SELECT
Rows.n.value('(@column1)[1]', 'varchar(20)'),
Rows.n.value('(@column2)[1]', 'nvarchar(100)'),
Rows.n.v... | <p>Stumbled across this question whilst having a very similar problem, I'd been running a query processing a 7.5MB XML file (~approx 10,000 nodes) for around 3.5~4 hours before finally giving up.</p>
<p>However, after a little more research I found that having typed the XML using a schema and created an XML Index (I'd... | <p>There is an <a href="http://msdn.microsoft.com/en-us/library/ms171769.aspx" rel="nofollow noreferrer">XML Bulk load</a> COM object (<a href="http://msdn.microsoft.com/en-us/library/ms171878.aspx" rel="nofollow noreferrer">.NET Example</a>) </p>
<p>From <a href="http://msdn.microsoft.com/en-us/library/ms171721.aspx"... | 8,638 |
<p>I've got MS Access database with linked tables, whenever each table is linked to a table in the same SQL Server database. I have a query inside Access that joins two tables (in particular I'm updating a table based on another using a join).</p>
<p>The question is does Access "download" all the table data before doi... | <p>According to Albert D. Kallal (Access MVP), Access does not pull the whole tables, except for complex views, where things can get messed up. However, it is best to use views on the server and link to the view, or to use pass-though queries.</p>
<p>Further information: <a href="http://support.microsoft.com/kb/303968... | <p>I've looked at SQL Profiler (unfortunately i don't have the actual log handy) and here's what i found:</p>
<ul>
<li>it selects all records from both tables</li>
<li>for each record in one table calls an UPDATE
So this will be slow.</li>
</ul>
| 45,329 |
<p>Is there any <strong>simple algorithm</strong> to determine the likeliness of 2 names representing the same person? </p>
<p>I'm not asking for something of the level that Custom department might be using. Just a simple algorithm that would tell me if 'James T. Clark' is most likely the same name as 'J. Thomas Clark... | <p>I've faced similar problem and tried to use Levenstein distance first, but it did not work well for me. I came up with an algorithm that gives you "similarity" value between two strings (higher value means more similar strings, "1" for identical strings). This value is not very meaningful by itself (if not "1", alwa... | <p>I doubt there is, considering even the <a href="http://www.upgradetravelbetter.com/2008/09/14/tired-of-secondary-screenings-change-your-name/" rel="nofollow noreferrer">Customs Department doesn't seem to have a satisfactory answer</a>...</p>
| 9,390 |
<p>I have a case that keeps coming up where I'm using a ListView or similar control with a simple array such as string[].</p>
<p>Is there a way to use the DataKeyNames property when you are binding to simple collections?</p>
| <p>You could do this with Linq:</p>
<pre><code>string [] files = ...;
var list = from f in files
select new { Letter = f };
// anonymous type created with member called Letter
lv.DataKeyNames = "Letter";
lv.DataSource = list;
lv.DataBind();
</code></pre>
| <p>Try using a Generic List with objects object. The example below is C# 3.0. Say you want a list of letters:</p>
<pre><code>public class LettersInfo
{
public String Letter { get; set; }
}
</code></pre>
<p>then make a list:</p>
<pre><code>List<LettersInfo> list = new List<LettersInfo>();
list.add(n... | 31,655 |
<p>I am having some trouble keeping an event handle alive for some reason.</p>
<p>My project is an outlook addin which prompts the user to do something when they send an email. Now, I have an event handler hooked up to the Sent Items folder so that when the sent email arrives in that folder it fires the prompt. The re... | <p>It is getting garage collected. If you post some of your code, I might be able to help.</p>
| <p>It is getting garage collected. If you post some of your code, I might be able to help.</p>
| 37,597 |
<p>I've been looking at NHibernate recently and trying to learn the ins and outs. One thing I did notice in a few articles was the use of BuildSchema to create a testable database.</p>
<p>The particular example used SqlLite as the database. Can BuildSchema be trusted to create your database or is it still best to crea... | <p>There are a couple of principles that I think are important to ensure:</p>
<ol>
<li>Release only from source control system (either a dedicated branch or a tag on mainline). No possibility of releasing directly from working directory.</li>
<li>Make push-to-production and push-to-staging processes utterly automated ... | <p>Denis Hennessy wrote a fine summary. As for tools, have a look at <a href="http://www.capify.org/" rel="nofollow noreferrer">Capistrano</a>.</p>
| 46,178 |
<p>I'm learning Haskell in the hope that it will help me get closer to functional programming. Previously, I've mostly used languages with C-like syntax, like C, Java, and D.</p>
<p>I have a little question about the coding style of an <code>if</code>/<code>else</code> control block used by the <a href="http://en.wiki... | <p>Haskell style is functional, not imperative! Rather than "do this then that," think about combining functions and describing <em>what</em> your program will do, not how.</p>
<p>In the game, your program asks the user for a guess. A correct guess is a winner. Otherwise, the user tries again. The game continues until... | <p>I use a coding style like your example from Wikibooks. Sure, it doesn't follow the C guidelines, but Haskell's not C, and it's fairly readable, especially once you get used to it. It's also patterned after the style of algorithms used in many textbooks, like Cormen.</p>
| 15,478 |
<p>VB 2008.</p>
<p>I have several text boxes on a form and I want each of them to use the same event handler. I know how to manually wire each one up to the handler, but I'm looking for a more generic way so if I add more text boxes they will automatically be hooked up to the event handler.</p>
<p>Ideas?</p>
<p>EDIT... | <p>Do something like this in your form's load event (C#, sorry, but it's easy to translate):</p>
<pre><code>private void Form1_Load(object sender, EventArgs e)
{
foreach (Control ctrl in this.Controls)
{
if (ctrl is TextBox)
{
TextBox tb = (TextBox)ctrl;
tb.TextChanged +... | <p>It might be possible with a macro, but otherwise, I a m not aware of anything that would automatically wire an control to a generic handler.</p>
<p>The only easy way I know of would be to select all appliciable textboxes, and simply set the eventhandler for the click event at the same time, but that isn't automatic... | 21,685 |
<p>Did anyone of you ever find a way of getting the Microsoft Report Viewer Control (Web) to work from within an Ajax UpdatePanel?</p>
| <p>The only way really is to create an iframe with the report in there iirc. However, <a href="http://forums.asp.net/p/1044194/1460759.aspx" rel="nofollow noreferrer">this post here</a> a guy claims he has a way to fix it with some code. albeit i havnt even tried this as I have never had a need to show any of my report... | <p>Never tried really, but I'm sure that control wouldn't work straight away. I'm pretty sure it needs to load some extra Javascript, because it adds so much complexity, so you might need to load those before updating the panel.</p>
| 19,280 |
<p>I am experimenting with using the FaultException and FaultException<T> to determine the best usage pattern in our applications. We need to support WCF as well as non-WCF service consumers/clients, including SOAP 1.1 and SOAP 1.2 clients.</p>
<p>FYI: using FaultExceptions with wsHttpBinding results in SOAP 1.2... | <p>This is my current workaround:</p>
<pre><code> /// <summary>
/// Replacement for the static methods on FaultCode to generate Sender and Receiver fault codes due
/// to what seems like bugs in the implementation for basicHttpBinding (SOAP 1.1). wsHttpBinding
/// (SOAP 1.2) seems to work just fi... | <p>Response from Microsoft:</p>
<p>As discussed in <a href="http://msdn.microsoft.com/en-us/library/ms789039.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms789039.aspx</a>, there are two methods outlined in the Soap 1.1 specification for custom fault codes:</p>
<p>(1) Using the "dot" notation as you... | 9,070 |
<p>Here are the specs that I'm trying to implement in a nutshell:</p>
<p>1) Some Alerts have to be sent on certain events in the application.</p>
<p>2) These Alerts have Users subscribe to them.</p>
<p>3) And the Users have set their own Notification preferences (e.g. Email and/or SMS).</p>
<p>I have not been able ... | <p>JMX can be a mechanism to solve this problem, but it's not the complete solution.</p>
<p>JMX provides facilities and services to your programs to allow clients to access monitoring data as well as allowing clients to make control calls to the application.</p>
<p>As you mentioned, one aspect of JMX is the notificat... | <p>Do you mean JMS (instead of JMX)? JMS is an messaging API while JMX is a monitoring/administration API.
Using JMS as the back end is a good way to implement the back-end messages, it will take care of decoupaging, load balancing, and persistency. But you still have to have a component that receives the messages and ... | 39,007 |
<p>Trying to do this sort of thing...</p>
<pre><code>WHERE username LIKE '%$str%'
</code></pre>
<p>...but using bound parameters to prepared statements in PDO. e.g.:</p>
<pre><code>$query = $db->prepare("select * from comments where comment like :search");
$query->bindParam(':search', $str);
$query->execute... | <p>Ah. Found a comment on php.net that reminded me of the answer; you need to wildcard your value before the bindParam is evaluated, and not worry about quoting it. So for example this works fine:</p>
<pre><code>$str = "%$str%";
$query = $db->prepare("select * from comments where comment like :search");
$query->... | <p>5 years later, in case anyone else stumbles upon this, there is an alternative method I've discovered. The accepted solution wasn't really feasible for my situation, but this method seems to get the job done as well:</p>
<pre><code>$query = $db->prepare("select * FROM table WHERE field LIKE CONCAT('%',:search,'%... | 8,579 |
<p>What is a good free/open source alternative to <a href="http://en.wikipedia.org/wiki/WebFOCUS" rel="nofollow noreferrer">WebFOCUS</a>? </p>
<p>Is there an ASP.NET way of getting info from an OLAP cube? </p>
<p><strong>Update:</strong> I chose Magnus Smith's answer as the correct one, but <a href="https://stackove... | <p>I am not aware of free analytical suite. But what is it you are trying to accomplish?</p>
<p>You can query an OLAP cube by using MDX queries with ADO.net. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms144785.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms144785.aspx</a></p>
... | <p>I am not aware of free analytical suite. But what is it you are trying to accomplish?</p>
<p>You can query an OLAP cube by using MDX queries with ADO.net. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms144785.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms144785.aspx</a></p>
... | 17,522 |
<p>I'm trying to prevent <code>bash</code> from saving duplicate commands to my history. Here's what I've got:</p>
<pre><code>shopt -s histappend
export HISTIGNORE='&:ls:cd ~:cd ..:[bf]g:exit:h:history'
export HISTCONTROL=erasedups
export PROMPT_COMMAND='history -a'
</code></pre>
<p>This works fine while I'm logg... | <p>As far as I know, it is not possible to do what you want. I see this as a bug in bash's history processing that could be improved.</p>
<pre><code>export HISTCONTROL=ignoreboth:erasedups # no duplicate entries
shopt -s histappend # append history file
export PROMPT_COMMAND="history -a" ... | <p>Here is what I use..</p>
<pre><code>[vanuganti@ ~]$ grep HIST .alias*
.alias:HISTCONTROL="erasedups"
.alias:HISTSIZE=20000
.alias:HISTIGNORE=ls:ll:"ls -altr":"ls -alt":la:l:pwd:exit:mc:su:df:clear:ps:h:history:"ls -al"
.alias:export HISTCONTROL HISTSIZE HISTIGNORE
[vanuganti@ ~]$
</code></pre>
<p>and working</p>
... | 43,912 |
<p>Before it stopped working, the stepper motor worked very well and didn't show any problem. I experienced this after I fixed a filament problem. The filament got stuck soI retracted to pull the filament out of the heat nozzle. But when I finished this, the extruder didn't work anymore...</p>
<p>I restarted the syste... | <p>I have found an answer. So dumb♂️♂️. It need to heat up nozzle before use extrude or retract command</p>
| <p>When you pulled the filament out of the extruder you most likely induced a voltage back into the stepper driver which fried it.</p>
| 1,642 |
<p>There's an existing function that ends in the following, where <code>d</code> is a dictionary:</p>
<pre><code>return d.iteritems()
</code></pre>
<p>that returns an unsorted iterator for a given dictionary. I would like to return an iterator that goes through the items sorted <em>by key</em>. How do I do that?</p>
| <p>Haven't tested this very extensively, but works in Python 2.5.2.</p>
<pre><code>>>> d = {"x":2, "h":15, "a":2222}
>>> it = iter(sorted(d.iteritems()))
>>> it.next()
('a', 2222)
>>> it.next()
('h', 15)
>>> it.next()
('x', 2)
>>>
</code></pre>
<p>If you are used ... | <p>sorted returns a list, hence your error when you try to iterate over it,
but because you can't order a dict you will have to deal with a list.</p>
<p>I have no idea what the larger context of your code is, but you could try adding an
iterator to the resulting list.
like this maybe?:</p>
<pre><code>return iter(sor... | 47,591 |
<p>For a single-server LAMP site (which is usually under quite high load), what is best way to use memcache? </p>
<p>Does it make sense to run the memcache daemon on the same server as the application, or is that just going to take valuable memory away from MySQL, giving a net performance loss. Does it even make sens... | <p>Usually, the recommendation (see <em>What about shared memory?</em> in the <a href="http://www.danga.com/memcached/" rel="noreferrer">memcached page</a>) is to run memcached on the same machines as web servers, on the premise that web applications are CPU-heavy (which memcached is not), whereas memcached is memory-h... | <p>Another option to memcached - depending on the scale on information you are caching, is caching in APC. You should be running that (or a similar op-code cache) to help speed the PHP page delivery anyhow, so if you are caching somewhere from a few, to a hundred or more smaller (I've got a few at around 15KB each, out... | 23,796 |
<p>How can I find or generate thousands of company names for testing and demo purposes? (Address, phone number, and related information would be nice too.)</p>
<p>I've got a system I'm building which includes business contact information. Pretty common no doubt. </p>
<p>My test/demo database currently has randomly... | <p>I use <a href="http://www.fakenamegenerator.com/faq.php" rel="nofollow noreferrer">Fake Name generator</a>:</p>
<blockquote>
<h3>What can I use the Fake Name Generator identities for?</h3>
<p>Thousands of individuals, companies, and government organizations have found useful and creative things to do with th... | <p>If you are simply looking to generate names, I would use one of the two above options. If you are looking for more complex data, Redgate makes a SQL data generator. I have never used this program, I simply know of its existence.</p>
| 28,125 |
<p>Does emacs have something like vi's “set number”, so that each line starts with its line number?</p>
| <p>Take a look at this article. It explains various ways to add line numbers to emacs:</p>
<p><a href="http://www.emacswiki.org/cgi-bin/wiki/LineNumbers" rel="nofollow noreferrer">http://www.emacswiki.org/cgi-bin/wiki/LineNumbers</a></p>
| <p>Try adding <a href="http://www.emacswiki.org/cgi-bin/wiki/LineNumbers" rel="nofollow noreferrer">linum.el</a> to your emacs dir / .emacs file.</p>
| 8,983 |
<p>I was trying to add a favicon to a website earlier and looked for a better way to implement this than to dump a <code>favicon.ico</code> file in the root of the website.</p>
<p>I found this nice little guide: <a href="http://www.w3.org/2005/10/howto-favicon" rel="noreferrer">How to Add a Favicon</a>. However, the p... | <p>This is what I always use: </p>
<pre><code><link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
</code></pre>
<p>The second one is for IE. The first one is for other browsers.</p>
| <p>This is how they're doing it right here on Stack Overflow:</p>
<pre><code><link rel="shortcut icon" href="/favicon.ico" />
</code></pre>
| 2,838 |
<p>I would like to create XML Schema for this chunk of xml, I would like to restrict the values of "name" attribute, so that in output document on and only one instance of day is allowed for each week day:</p>
<pre><code><a>
<day name="monday" />
<day name="tuesday" />
<day name="wednesday" ... | <p>You need something like this:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="a">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="... | <p>Try this:</p>
<pre><code><xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="a">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="day">
... | 21,446 |
<p>I made a discovery some time back. Just follow these steps:</p>
<p>Create a .doc/.xls/.ppt file in office 2003. Keep some test data in there and close the file. Now rename the file to change it's file extension to a random string, taking care that it is unassociated, like test.asdfghjkl etc.
Double click the file a... | <p>Do you have the "View extensions for known types" option on?</p>
<p>EDIT: @Comments....
Yes, its a stupid/insulting question, but when troubleshooting a problem I have learned to assume nothing, and trust the users 0%. </p>
<p>BUT, I tried it, and you're right. Its stupid that MS has this kind of behavior, and it ... | <p>I can't seem to make this happen now, but I know I saw <a href="http://nedbatchelder.com/blog/200506/windows_shell_reads_xml_processing_instructions.html" rel="nofollow noreferrer">Windows reading XML processing instructions</a> a few years back. Maybe that is what's going on?</p>
| 35,168 |
<p>Most often the cleanup rules (Preferences > Java > Code Style > Clean Up) in Eclipse work perfectly and create nice-looking code.</p>
<p>But sometimes, especially with comments and concatenated string snippets (like inline SQL queries), the cleanup just messes things up, and destroys my formatting.</p>
<p>Is there... | <p>I assume you do not really mean ‘Clean Up’, but the ‘Format source code’ option hidden within. It is configured in Preferences > Java > Code Style > Formatter. And, indeed, there is an option called ‘On/Off Tags’. Sadly, it’s off by default. You would now write it like so:</p>
<pre><code>// @formatter:off
StringBui... | <p>No. (To the best of my knowledge, and I have had the same problem and have looked many times hard and long...)</p>
| 20,923 |
<p>I've created a c# webservice that allows our front end support teams to view and update a few selected Active Directory values using system.directoryservices</p>
<p>Fields that I want to update are [job] title, department, telephone and employeeid.</p>
<p>I can use a service account with "delegates rights" to upda... | <p><strong>ANSWER</strong></p>
<p><em>The ADS_SCHEMA_ID_GUID_USER GUID allows you to update the base user class details, including the employee id</em></p>
<p><a href="http://www.microsoft.com/technet/scriptcenter/topics/security/exrights.mspx" rel="nofollow noreferrer">Based on MSDN article</a></p>
<p>The vbscript ... | <p>A sample of the code (the moving parts at least)</p>
<pre><code>string distinguishedname = "CN=Wicks\, Guy,OU=Users,DC=ad,DC=com"
using (DirectoryEntry myDirectoryEntry = new DirectoryEntry(string.Format("LDAP://{0}", distinguishedname), null, null, AuthenticationTypes.Secure))
{
try
{
myDirectoryEn... | 34,344 |
<p>I have a text file with multiple records. I want to search a name and date, for example if I typed <code>JULIUS CESAR</code> as name then the whole data about <code>JULIUS</code> will be extracted. What if I want only to extract information?</p>
<pre><code>Record number: 1
Date: 08-Oct-08
Time: 23:45:01
Name: JULIU... | <p>If it is one line per entry, you could use a regular expression such as:</p>
<pre><code>$name = "JULIUS CESAR";
</code></pre>
<p>Then use: </p>
<pre><code>/$name/i
</code></pre>
<p>to test if each line is about "JULIUS CESAR." Then you simply have to use the following regex to extract the information (once you ... | <p>In PHP, you can run a SQL select statement like:</p>
<p>"SELECT * WHERE <code>name</code> LIKE 'JULIUS%';"</p>
<p>There are native aspects of PHP where you can get all of your results in an associative array. I'm pretty sure it's ordered by row order. Then you can just do something like this:</p>
<p>echo implod... | 21,857 |
<p>I'm working with a fairly simple database, from a Java application. We're trying to insert about 200k of text at a time, using the standard JDBC mysql adapter. We intermittently get a <code>com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column error.</code></p>
<p>The column type is <code>l... | <p>Check that your UTF-8 data is all 3-byte Unicode. If you have 4-byte characters (legal in Unicode and Java, illegal in MySQL 5), it can throw this error when you try to insert them. This is an <a href="http://bugs.mysql.com/bug.php?id=25666" rel="noreferrer">issue that should be fixed</a> in MySQL 6.0.</p>
| <p>I just hit this problem and solved it by removing all the non-standard ascii characters in my text (following the UTF-8 advice above).</p>
<p>I had the problem on a Debian 4, Java 5 system; but the same code worked fine with Ubuntu 9.04, Java 6. Both run MySql 5.</p>
| 9,878 |
<blockquote>
<p>Write a class ListNode which has the following properties:</p>
<ul>
<li>int value;</li>
<li>ListNode *next;</li>
</ul>
<p>Provide the following functions:</p>
<ul>
<li>ListNode(int v, ListNode *l)</li>
<li>int getValue();</li>
<li>ListNode* getNext();</li>
<li>void insert(int i);</li>
<li>bool listconta... | <p>What unwind and ckarmann say. Here is a hint, i implement listcontains for you to give you the idea how the assignment could be meant:</p>
<pre><code>class ListNode {
private:
int value;
ListNode * next;
public:
bool listcontains(int v) {
// does this node contain the value?
if(value =... | <p>Another improvement, in the list code, you shouldn't traverse the whole list to get the length, you can keep a counter about the amount of elements updating it on insertions/deletions and return it.</p>
| 41,924 |
<p>I write tons of python scripts, and I find myself reusing lots code that I've written for other projects. My solution has been to make sure the code is separated into logical modules/packages (this one's a given). I then make them setuptools-aware and publish them on PyPI. This allows my other scripts to always have... | <p>I have been doing the same thing. Extract common functionality, pretty the code up with extra documentation and unit tests/ doctests, create an easy_install setup.py, and then release on PyPi. Recently, I created a single <a href="http://code.google.com/p/7oars/" rel="nofollow noreferrer">Google Code site</a> wher... | <p>I store it all offline in a logical directory structure, with commonly used modules grouped as utilities. This means it's easier to control which versions I publish, and manage. I also automate the build process to interpret the logical directory structure.</p>
| 16,490 |
<p>The following code works as expected in both Python 2.5 and 3.0:</p>
<pre><code>a, b, c = (1, 2, 3)
print(a, b, c)
def test():
print(a)
print(b)
print(c) # (A)
#c+=1 # (B)
test()
</code></pre>
<p>However, when I uncomment line <strong>(B)</strong>, I get an <code>UnboundLocalError: 'c' not... | <p>Python treats variables in functions differently depending on whether you assign values to them from inside or outside the function. If a variable is assigned within a function, it is treated by default as a local variable. Therefore, when you uncomment the line, you are trying to reference the local variable <cod... | <p>You can also get this message if you define a variable with the same name as a method.</p>
<p>For example:</p>
<pre><code>def teams():
...
def some_other_method():
teams = teams()
</code></pre>
<p>The solution, is to rename method <code>teams()</code> to something else like <code>get_teams()</code>.</p>
<p>... | 48,381 |
<p>Is there a project that maintains annotations for patterns?</p>
<p><p>For example, when I write a builder, I want to mark it with <code>@Builder</code>.</p>
<p><p>Annotating in this way immediately provides a clear idea of what the code implements. Also, the Javadoc of the <code>@Builder</code> annotation can refe... | <p>This seems like a misuse of annotations to me. Sure, I could see why you might want to note what design pattern a class is helping to implement, but just using the Javadoc and/or the name of the class seems more appropriate. The name of the pattern that you're using is of no actual importance to the code itself... p... | <p>First off all this is a very good idea and I'm only hanging out here because I googled for a "design pattern annotation" library. Good I found this! I will check it out and give feed back on it soon.</p>
<p>To all the skeptics: sorry obviously most of you are not very experienced in the topic of design patters. E.g... | 15,502 |
<p>I have a Linq query that I want to call from multiple places:</p>
<pre><code>var myData = from a in db.MyTable
where a.MyValue == "A"
select new {
a.Key,
a.MyValue
};
</code></pre>
<p>How can I create a met... | <p>IQueryable and IEnumerable both work. But you want to use a type specific version, IQueryable<code><</code>T<code>></code> or IEnumerable <code><</code>T<code>></code>.</p>
<p>So you'll want to create a type to keep the data.</p>
<pre><code>var myData = from a in db.MyTable
where a.MyValue... | <p>If you want to return, you need a type.</p>
<p>Instead of <code>var</code>, declare using <code>IEnumerable<></code> and return that variable. Iterating through it actually executes the query.</p>
| 7,883 |
<p>I find myself writing code that looks like this a lot:</p>
<pre><code>set<int> affected_items;
while (string code = GetKeyCodeFromSomewhere())
{
if (code == "some constant" || code == "some other constant") {
affected_items.insert(some_constant_id);
} else if (code == "yet another constant" ||... | <p>Since you don't seem to care about the actual values in the set you could replace it with setting bits in an int. You can also replace the linear time search logic with log time search logic. Here's the final code:</p>
<pre><code>// Ahead of time you build a static map from your strings to bit values.
std::map<... | <p>Obviously, it will depend on the specific circumstances, but it might be better to have the functions that you call keep track of whether they've already been run and exit early if required. </p>
| 29,951 |
<p>Short background: We are just starting to migrate/reimplement an ERP system to Java with Hibernate, targeting a concurrent user count of 50-100 users using the system. We use MS SQL Server as database server, which is good enough for this loads.</p>
<p>Now, the old system doesn't use any transactions at all and rel... | <p>99 times out of 100, read committed is the right answer. That ensures that you only see changes that have been committed by the other session (and, thus, results that are consistent, assuming you've designed your transactions correctly). But it doesn't impose the locking overhead (particularly in non-Oracle databa... | <p>Read Uncommitted is definitely the underdog in most forums. However, there are reasons to use it that go beyond a matter of "speed versus accuracy" that is often pointed out.</p>
<p>Let's say you have:</p>
<ul>
<li>Transaction T1: Writes B, Reads A, (some more work), Commit.</li>
<li>Transaction T2: Writes A, Read... | 47,558 |
<p>Ruby has a wealth of conditional constructs, including <code>if</code>/<code>unless</code>, <code>while</code>/<code>until</code> etc.</p>
<p>The <code>while</code> block from C:</p>
<pre><code>while (condition) {
...
}
</code></pre>
<p>can be directly translated to Ruby:</p>
<pre><code>while condition
... | <p>...The best I could come up with is the <code>loop</code> construct with a <code>break</code> at the end: </p>
<pre><code>loop do
...
break unless condition
end
</code></pre>
| <p>You can use</p>
<pre><code>while condition
...
end
</code></pre>
| 23,128 |
<p>Can anyone help me find/confirm the information needed to setup the CR-10 in the Cura Software</p>
<p>I have following settings from research:</p>
<p><strong>Printer Settings</strong></p>
<ul>
<li>x = 300 mm</li>
<li>y = 300 mm</li>
<li>z = 400 mm</li>
<li>Build Plate = Rectangular</li>
<li>Mach... | <p><strong>GCode flavor</strong>: the firmware your machine uses. Google tells me CR-10 uses Marlin, so you should select that. Volumetric Marlin is not very common.</p>
<p>Print Head Settings
<strong>X/Y min/max</strong> define the bounding box of the area your print head takes up. Measure the distance from the centr... | <p>In addition to <a href="/a/4438">this answer</a>, the "Machine Center is Zero", should <strong>not</strong> be checked. It will begin the print in the current location of the Printing Head.</p>
| 653 |
<p>Yes, Podcasts, those nice little Audiobooks I can listen to on the way to work. With the current amount of Podcasts, it's like searching a needle in a haystack, except that the haystack happens to be the Internet and is filled with too many of these "Hot new Gadgets" stuff :(</p>
<p>Now, even though <stron... | <p>I like</p>
<p><strong>General Software</strong></p>
<ul>
<li><a href="https://blog.stackoverflow.com/category/podcasts/">Stackoverflow</a> (perhaps too obvious)</li>
<li><a href="http://deepfriedbytes.com/" rel="nofollow noreferrer">Deep Fried Bytes</a></li>
<li><a href="http://www.hanselminutes.com/" rel="nofollow ... | <p>Suggest someone with the reputation to do it revise this question to say, "What good technology podcasts are out there?"</p>
<p>I've got all kinds of audio fiction I could recommend, but then this question really runs off into the weeds.</p>
| 2,398 |
<p>I'd like to add an extra motor to my board and I'm not sure where I went wrong. The motor will be used to spin a rotating wheel/carriage of potential hot ends to switch to. Because it's just a motor it doesn't need a heatrod or a temperature sensor. </p>
<p>I had just a MKS_BASE 1.0 board, so I purchased a RAMPS 1.... | <p><code>D35</code>, <code>D37</code>, <code>D17</code> are the pin labels on the Arduino Mega. <em>These do not correspond to pin numbers within Marlin</em>.</p>
<p>I believe that <code>D35</code> actually corresponds to marlin pin <code>49</code> and this is the number you should enter in your firmware. You can find... | <p><code>D35</code>, <code>D37</code>, <code>D17</code> are the pin labels on the Arduino Mega. <em>These do not correspond to pin numbers within Marlin</em>.</p>
<p>I believe that <code>D35</code> actually corresponds to marlin pin <code>49</code> and this is the number you should enter in your firmware. You can find... | 1,421 |
<p>How can I figure out, how many files needs to be recompiled <em>before</em> I start the build process.</p>
<p>Sometimes I don't remember how many basic header files I changed so a Rebuild All would be better than a simple build. There seams to be no option for this, but IMHO it must be possible (f.e. XCode give me ... | <p>You probably mean RRSIG ANY (otherwise, the order is wrong, the class needs to be after the type)</p>
<pre><code>>>> print myresolver.query('sources.org', 'RRSIG', 'ANY')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/dns/resolv... | <p>If you try this, what happens?</p>
<pre><code>print myresolver.query('sources.org', 'ANY', 'RRSIG')
</code></pre>
| 10,830 |
<p>What is the best way to do GUIs in <a href="http://en.wikipedia.org/wiki/Clojure" rel="noreferrer">Clojure</a>?</p>
<p>Is there an example of some functional <a href="http://en.wikipedia.org/wiki/Swing_%28Java%29" rel="noreferrer">Swing</a> or <a href="http://en.wikipedia.org/wiki/Standard_Widget_Toolkit" rel="nore... | <p>I will humbly suggest <a href="https://github.com/daveray/seesaw">Seesaw</a>. </p>
<p><a href="https://gist.github.com/1441520">Here's a REPL-based tutorial</a> that assumes no Java or Swing knowledge.</p>
<hr>
<p>Seesaw's a lot like what @tomjen suggests. Here's "Hello, World":</p>
<pre class="lang-clj prettypr... | <p>Clojure and SWT is the best approach for doing GUI(s). Essentially, SWT is a plug and play style approach for developing software.</p>
| 28,860 |
<p>By default Windows (XP) shows the <strong>underlined hotkeys</strong> only, when ALT is pressed. This can be changed in display-properties in the subdialog "Effects" so, that the hotkeys are <strong>always underlined</strong></p>
<p>How can it be changed programmatically? Which API-call or registry-setting can be u... | <p>I found the solution, how to query and to set:</p>
<pre><code>BOOL b
SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &b, 0);
if (!b) {
b = TRUE;
SystemParametersInfo(SPI_SETKEYBOARDCUES, 0, &b, 0);
}
</code></pre>
| <p>Do you mean you want to change this system-wide setting, or that you want to be able to override the behavior only in your program?</p>
<p>If it's the latter and you're using the Win32 API, it looks like you might be able to catch the WM_CHANGEUISTATE notification: <a href="http://blogs.msdn.com/oldnewthing/archive... | 30,395 |
<p>Does anyone have any pointers on how to read the Windows EventLog without using JNI? Or if you <em>have to</em> use JNI, are there any good open-source libraries for doing so?</p>
| <p>JNA 3.2.8 has both an implementation for all event logging functions and a Java iterator. Read <a href="http://code.dblock.org/ShowPost.aspx?id=125" rel="nofollow">this</a>.</p>
<pre><code>EventLogIterator iter = new EventLogIterator("Application");
while(iter.hasNext()) {
EventLogRecord record = iter... | <p>You'll need to use <a href="http://en.wikipedia.org/wiki/Java_Native_Interface" rel="nofollow noreferrer">JNI</a>.</p>
| 10,323 |
<p>I'm trying to replace the programs that run from my startup directory with a batch script. The batch script will simply warn me that the programs are going to run and I can either continue running the script or stop it. </p>
<p>Here's the script as I have written so far:</p>
<pre><code>@echo off
echo You are abo... | <p>This works:</p>
<pre>
@echo off
echo You are about to run startup programs!
pause
::load outlook
start /b "" "C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE" /recycle
::load Visual Studio 2008
start /b "" "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
</pre>
| <p>There is the <code>start</code> command that will behave much like if you clicked the files in Explorer.</p>
| 36,627 |
<p>I am trying to build gdb for armv6 architecture. I will be compiling this package on a Fedora Linux-Intel x86 box. I read the process of installing the gdb, like</p>
<ol>
<li><p>Download the source pachage</p></li>
<li><p>run <code>configure -host</code></p></li>
<li><p><code>make</code></p></li>
</ol>
<p>But I go... | <p>We (www.rockbox.org) use the arm target for a whole batch of our currently working DAPS. The target we specify is usually arm-elf, rather than arm-linux.</p>
| <p>target/host is usually the target tool chain you would be using (mostly arm-linux)</p>
| 9,562 |
<p>I have implemented a simple file upload-download mechanism. When a user clicks a file name, the file is downloaded with these HTTP headers:</p>
<pre><code>HTTP/1.1 200 OK
Date: Tue, 30 Sep 2008 14:00:39 GMT
Server: Microsoft-IIS/6.0
Content-Disposition: attachment; filename=filename.doc;
Content-Type: application/o... | <p>gmail handles file name escaping somewhat differently: the file name is quoted (double-quotes), and single-byte periods are not URL-escaped.
This way, the long file name in the question is OK. </p>
<pre><code>Content-Disposition: attachment; filename="%E3%81%82%E3%81%82%E3%81%82%E3%81%82%E3%81%82%E3%81%82%E3%81%82... | <p>I think this issue is fixed in IE8, I have seen it working in IE 8.</p>
| 18,498 |
<p>Let's say you've inherited a C# codebase that uses one class with 200 static methods to provide core functionality (such as database lookups). Of the many nightmares in that class, there's copious use of Hungarian notation (the bad kind).</p>
<p>Would you refactor the variable names to remove the Hungarian notation... | <p>Refactor -- I find Hungarian notation on that scale really interferes with the natural readability of the code, and the exercise is a good way of getting familiar with what's there.</p>
<p>However, if there are other team members who know the code base you would need consensus on the refactoring, and if any of the ... | <p>I love Hungarian notation. Don't understand why you would want to get rid of it.</p>
| 24,230 |
<p>I have used IPC in Win32 code a while ago - critical sections, events, and semaphores.</p>
<p>How is the scene in the .NET environment?
Are there any tutorial explaining all available options and when to use and why?</p>
| <p>Most recent Microsoft's stuff in IPC is <a href="http://en.wikipedia.org/wiki/Windows_Communication_Foundation" rel="noreferrer">Windows Communication Foundation</a>. Actually there is nothing new in the lower level (tcp, upd, named pipes etc) But WCF simplifies IPC development greatly.</p>
<p>Useful resource:</p>
... | <p>There is also .NET Remoting, which I found quite cool, but I guess they are obsoleting it now that they have WCF.</p>
| 8,003 |
<p>How would you go about proving that two queries are functionally equivalent, eg they will always both return the same result set.</p>
<hr>
<p>As I had a specific query in mind when I was doing this, I ended up doing as @dougman suggested, over about 10% of rows the tables concerned and comparing the results, ensur... | <p>The best you can do is compare the 2 query outputs based on a given set of inputs looking for any differences. To say that they will always return the same results for all inputs really depends on the data.</p>
<p>For Oracle one of the better if not best approaches (very efficient) is here (<kbd>Ctrl</kbd>+<kbd>F<... | <p>You don't.</p>
<p>If you need a high level of confidence that a performance change, for example, hasn't changed the output of a query then test the hell out it.</p>
<p>If you need a really high level of confidence .. then errrm, test it even more.</p>
<p>Massive level's of testing aren't that hard to cobble toget... | 8,101 |
<p>I am trying to create a custom subclass of NSScroller. I have created the class, and set it as the vertical scroller on an NSScrollView in IB. When I run my project, the <code>drawRect:</code> method is called for my subclass, so I know that it is properly connected.</p>
<p>Now, How do I change the width of my fanc... | <p>In your NSScroller subclass, you have to override scrollerWidth:</p>
<pre><code>+(CGFloat)scrollerWidth
{
return 30.0;
}
</code></pre>
<p>This is the value that NSScrollView uses to define the frame for your component when it sets it up.</p>
| <p>You can use categories to override the scroller width method for all NSScrollers.</p>
<p>Eg. In NSScroller-MyScroller.h:</p>
<pre><code>#import <Cocoa/Cocoa.h>
@interface NSScroller (MyScroller)
+ (CGFloat)scrollerWidth;
+ (CGFloat)scrollerWidthForControlSize: (NSControlSize)controlSize;
@end
</code></pre... | 39,156 |
<p>Ok, I'm using the term "Progressive Enhancement" kind of loosely here but basically I have a Flash-based website that supports deep linking and loads content dynamically - what I'd like to do is provide alternate content (text) for those either not having Flash and for search engine bots. So, for a user with flash t... | <p>Looking at the solutions you linked... it is actually as simple as my frivolous comment!</p>
<p>Here's a version of the Zach Leatherman code that prepends "In " for future dates for you. As you can see, the changes are very minor.</p>
<pre><code> function humane_date(date_str){
var time_formats = [
... | <p>Heh - I actually wrote a function to do this exact thing yesterday (and it's not on this computer so I'll just have to try to remember it)</p>
<p>I extended the Date prototype class, but this could quite easily just be put into a regular function.</p>
<pre><code>Date.prototype.toRelativeTime = function(otherTime) ... | 20,389 |
<p>I'm looking to create an ValidationRule class that validates properties on an entity type object. I'd really like to set the name of the property to inspect, and then give the class a delegate or a lambda expression that will be evaluated at runtime when the object runs its IsValid() method. Does anyone have a sni... | <p>Really, what you want to use is <code>Func<T,bool></code> where T is the type of the item you want to validate. Then you would do something like this</p>
<pre><code>validator.AddValidation(item => (item.HasEnoughInformation() || item.IsEmpty());
</code></pre>
<p>you could store them in a <code>List<Fun... | <p>Would a rule definition syntax like this one work for you?</p>
<pre><code> public static void Valid(Address address, IScope scope)
{
scope.Validate(() => address.Street1, StringIs.Limited(10, 256));
scope.Validate(() => address.Street2, StringIs.Limited(256));
scope.Validate(() => address.Co... | 17,178 |
<p>My MySQL database contains several tables using different storage engines
(specifically myisam and innodb). How can I find out which tables are
using which engine?</p>
| <pre><code>SHOW TABLE STATUS WHERE Name = 'xxx'
</code></pre>
<p>This will give you (among other things) an <code>Engine</code> column, which is what you want.</p>
| <p>go to information_schema database there you will find 'tables' table then select it;</p>
<p>Mysql>use information_schema;
Mysql> select table_name,engine from tables;</p>
| 26,252 |
<p>I have lots of unrelated named things that I'd like to do quick searches against. An "aardvark" is always an "aardvark" everywhere, so hashing the string and reusing the integer would work well to speed up comparisons. The entire set of names is unknown (and changes over time). What is a fast string hashing algorith... | <p>One of the <a href="http://isthe.com/chongo/tech/comp/fnv/" rel="noreferrer">FNV variants</a> should meet your requirements. They're fast, and produce fairly evenly distributed outputs.</p>
| <p><a href="http://en.wikipedia.org/wiki/Cyclic_redundancy_check" rel="nofollow noreferrer">CRC-32</a>. There is about a trillion links on google for it.</p>
| 13,928 |
<p>I'm tyring to convert a MSVC project from VS 2005 to VS 2008. It contains a IDL file that outputs a header and stubs used for RPC. The VS 2005 project uses MIDL.exe version 6.00.0366. The VS 2008 project uses MIDL.exe version 7.00.0500.</p>
<p>Here's the problem: MIDL v6 outputs the following prototype for me to ... | <p>Looks like I can answer my own question...</p>
<p>MIDL v6 appears to automatically default the handle type to auto_handle for the server prototypes. MIDL v7 does not, so the solution is to use a Server.acl file with the auto_handle setting in it. This outputs a Server.h file with function prototypes that is the sa... | <p>The handle_t IDL_handle is for the explicit RPC binding handle. On the server side, you can do cool stuff with it like pull the calling client's token for impersonation through the various RPC functions, but if you don't need to use it, it is fine to just set it as an unreferenced parameter (UNREFERENCED_PARAMETER(... | 44,785 |
<p>I use <a href="http://www.crockford.com/javascript/jsmin.html" rel="nofollow noreferrer">jsmin</a> to compress my javascript files before uploading them to production.</p>
<p>Since I tend to have one "code-behind" javascript file per page, I wind up doing this a lot.</p>
<p>I installed a Windows Powertoy that adds... | <p>Here is how to add an entry to your context menu for .js files:</p>
<pre><code>[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JSFile\shell\JSMinify]
@="JSMinify"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JSFile\shell\JSMinify\Command]
@="cmd.exe /c \"implement whatever cmd-friendly functions you want here (can use %1 and %%f) "... | <p>you could drop a link to a batch script into the user sendto directory. Something like</p>
<pre><code>jsmin %1 script.min.js
</code></pre>
<p>which is what I usually do</p>
| 29,463 |
<p>In a C# (feel free to answer for other languages) loop, what's the difference between <code>break</code> and <code>continue</code> as a means to leave the structure of the loop, and go to the next iteration?</p>
<p>Example:</p>
<pre><code>foreach (DataRow row in myTable.Rows)
{
if (someConditionEvalsToTrue)
... | <p><code>break</code> will exit the loop completely, <code>continue</code> will just <strong>skip</strong> the current iteration.</p>
<p>For example:</p>
<pre><code>for (int i = 0; i < 10; i++) {
if (i == 0) {
break;
}
DoSomeThingWith(i);
}
</code></pre>
<p>The break will cause the loop to ex... | <p>As for other languages:</p>
<pre class="lang-vb prettyprint-override"><code> 'VB
For i=0 To 10
If i=5 then Exit For '= break in C#;
'Do Something for i<5
next
For i=0 To 10
If i=5 then Continue For '= continue in C#
'Do Something for i<>5...
Next
</code><... | 2,816 |
<p>What is a preferred way to store recurring time windows? <br />
For example. If I have a calendar system where I need to be able to accommodate daily, weekly or monthly recurring events, what sort of time management system is best? <br /><br />
How is this best represented in a database? </p>
<p><strong>More Detail... | <p>It's like boost::ref, as far as I know. Basically, a reference which can be copied. Very useful when binding to functions where you need to pass parameters by reference.</p>
<p>For example (using boost syntax):</p>
<pre><code>void Increment( int& iValue )
{
iValue++;
}
int iVariable = 0;
boost::function&l... | <p><code>reference_wrapper<T></code> is an immensely useful and simple library. Internally the <code>reference_wrapper<T></code> stores a pointer to T. But the interface it exposes does not contain any pointer notation. </p>
<ul>
<li>It allows the reference to behave like other simple objects - a <code>ref... | 23,541 |
<p>Is there a way to view the key/value pairs of a NSDictionary variable through the Xcode debugger? Here's the extent of information when it is fully expanded in the variable window:</p>
<pre><code>Variable Value Summary
jsonDict 0x45c540 4 key/value pairs
NSObject {...}
isa 0xa06e0720
</code></pre>
... | <p>In the gdb window you can use <code>po</code> to inspect the object.</p>
<p>given:</p>
<pre><code>NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
[dict setObject:@"foo" forKey:@"bar"];
[dict setObject:@"fiz" forKey:@"buz"];
</code></pre>
<p>setting a breakpoint after the objects are added you can ... | <p>You can also use <a href="http://cocoadev.com/wiki/NSLog" rel="nofollow noreferrer">NSLog</a>.</p>
<p>Also you can go in Debug area or xcode, then find out <code>All Variables, Registers, Globals and Statics</code> then select your variable. Right click on it. Then select <code>Print description of "...."<... | 13,787 |
<p>In Python, how do I jump to a file in the Windows Explorer? I found a solution for jumping to folders:</p>
<pre><code>import subprocess
subprocess.Popen('explorer "C:\path\of\folder"')
</code></pre>
<p>but I have no solution for files.</p>
| <p>From <a href="http://www.geoffchappell.com/studies/windows/shell/explorer/cmdline.htm" rel="noreferrer">Geoff Chappell's <em>The Windows Explorer Command Line</em></a></p>
<pre><code>import subprocess
subprocess.Popen(r'explorer /select,"C:\path\of\folder\file"')
</code></pre>
| <p>Code To Open Folder In Explorer:</p>
<pre class="lang-py prettyprint-override"><code>import os
import ctypes
SW_SHOWDEFAULT = 10
path_to_open = os.getenv('windir')
ctypes.windll.shell32.ShellExecuteW(0, "open", path_to_open, 0, 0, SW_SHOWDEFAULT)
</code></pre>
| 35,680 |
<p>If I have a native C++ windows program (i.e. the entry point is WinMain) how do I view output from console functions like std::cout?</p>
| <p>Check out <a href="http://dslweb.nwnexus.com/~ast/dload/guicon.htm" rel="noreferrer">Adding Console I/O to a Win32 GUI App</a>. This may help you do what you want. </p>
<p>If you don't have, or can't modify the code, try the suggestions found <a href="http://support.microsoft.com/kb/110930/en-us" rel="noreferrer">... | <p>Since there's no console window, this is <strike>impossible</strike> difficult. (Learn something new every day - I never knew about the console functions!)</p>
<p>Is it possible for you to replace your output calls? I will often use TRACE or OutputDebugString to send information to the Visual Studio output window.... | 23,303 |
<p>Exception Thrown: "System.ComponentModel.ReflectPropertyDescriptor is not marked as Serializable"</p>
<p>Does this mean I missed marking something as serializable myself, or is this something beyond my control?</p>
| <p>Can you give more context as to when this happens, and with which serializer? Most serializers have the ability to ignore certain members - <code>NonSerializedAttribute</code> for <code>BinaryFormatter</code>, <code>XmlIgnoreAttribute</code> for <code>XmlSerializer</code>, etc.</p>
<p>Having a <code>PropertyDescrip... | <p>Do you have a field of this type in your class. If so, you will have to implement ISerializable yourself -- the automatic implementation requires that all of your fields are marked as Serializable.</p>
| 22,084 |
<p>I am creating a small application that will be deployed on Window. The database will have less than 10 tables. </p>
<p>Instead of installing a database on the client box is using XML documents for the database and LINQ going to cost in performance of queries, waiting for the XML file to be loaded and be written?... | <p>I would avoid it. I personally would use something like SqlExpress for the DB, or an .mdb file. The problem becomes when that Xml file starts getting large, or requires a change to the format (i.e. an update to a table's structure), processing that becomes a PITA.</p>
| <p>Adding some references to MagicKat's answer:</p>
<p>Not very portable, but free and limited -</p>
<p><a href="http://www.microsoft.com/express/sql/download/" rel="nofollow noreferrer">SQL Server 2008 Express</a></p>
<p>Microsoft <a href="http://en.wikipedia.org/wiki/Microsoft_Jet_Database_Engine" rel="nofollow no... | 19,304 |
<p>Is it possible to inspect the return value of a function in gdb assuming the return value is <strong>not</strong> assigned to a variable?</p>
| <p>I imagine there are better ways to do it, but the <a href="http://www.chemie.fu-berlin.de/chemnet/use/info/gdb/gdb_6.html#SEC37" rel="noreferrer">finish</a> command executes until the current stack frame is popped off and prints the return value -- given the program</p>
<pre><code>int fun() {
return 42;
}
int ... | <p>Here's how todo this with no symbols.</p>
<pre><code>gdb ls
This GDB was configured as "ppc64-yellowdog-linux-gnu"...
(no debugging symbols found)
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) break __libc_start_main
Breakpoint 1 at 0x10013cb0
(gdb) r
Starting program: /bin/ls
(no debugging sym... | 33,572 |
<p>Which method is preferred?</p>
<pre><code>Session.Remove("foo");
Session["foo"] = null;
</code></pre>
<p>Is there a difference?</p>
| <blockquote>
<p>Is there a difference?</p>
</blockquote>
<p>There is.
<code>Session.Remove(key)</code> deletes the entry (both key & value) from the dictionary while <code>Session[key] = null</code> assigns a value (which happens to be null) to a key. After the former call, the key won't appear in the <code>Ses... | <p>The biggest difference is how you read from session.</p>
<pre><code>if(Session.ContainsKey["foo"]) { return Session["foo"]; }
</code></pre>
<p>or</p>
<pre><code>if(Session["foo"] != null) { return Session["foo"]; }
</code></pre>
<p>If you use the first method, setting the value to null will not work, and you sho... | 32,760 |
<p>I have a site with multiple document libraries in it. One of the site users has full control of the site & at one point, instead of creating a new document library, they renamed the default document library from "Shared Documents" to "Correspondence". Now they've opened the document library in windows explorer... | <p>Renaming the document library in SharePoint Designer changes the address.</p>
| <p>Open the library in Windows Explorer, and just rename the folder. Works in Sharepoint Foundation 2010.</p>
| 30,206 |
<p>After reading Jeff's blog post on <a href="http://www.codinghorror.com/blog/archives/001167.html" rel="noreferrer">Protecting Your Cookies: HttpOnly</a>. I'd like to implement HttpOnly cookies in my web application.</p>
<p>How do you tell tomcat to use http only cookies for sessions?</p>
| <p>httpOnly is supported as of Tomcat 6.0.19 and Tomcat 5.5.28.</p>
<p>See the <a href="http://tomcat.apache.org/tomcat-6.0-doc/changelog.html" rel="noreferrer">changelog</a> entry for bug 44382. </p>
<p>The last comment for bug <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=44382" rel="noreferrer">44382... | <p>Implementation: in Tomcat 7.x/8.x/9.x</p>
<p>Go to Tomcat >> conf folder
Open web.xml and add below in session-config section</p>
<pre><code> <cookie-config>
<http-only>true</http-only>
<secure>true</secure>
</cookie-config>
</code></pre>
| 5,346 |
<p>I have a very simple jQuery Datepicker calendar:</p>
<pre><code>$(document).ready(function(){
$("#date_pretty").datepicker({
});
});
</code></pre>
<p>and of course in the HTML...</p>
<pre><code><input type="text" size="10" value="" id="date_pretty"/>
</code></pre>
<p>Today's date is nicely highlig... | <p><strong>Update: There are reports this no longer works in Chrome.</strong></p>
<p>This is concise and does the job (obsolete):</p>
<pre><code>$(".date-pick").datepicker('setDate', new Date());
</code></pre>
<p>This is less concise, utilizing <a href="https://www.w3schools.com/jquery/jquery_chaining.asp" rel="nore... | <pre><code>$(function()
{
$('.date-pick').datePicker().val(new Date().asString()).trigger('change');
});
</code></pre>
<p>Source: <a href="http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerDefaultToday.html" rel="nofollow noreferrer">http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePic... | 28,909 |
<p>I have a program which needs to behave slightly differently on Tiger than on Leopard. Does anybody know of a system call which will allow me to accurately determine which version of Mac OS X I am running. I have found a number of macro definitions to determine the OS of the build machine, but nothing really good to ... | <p><a href="http://cocoadevcentral.com/articles/000067.php" rel="nofollow noreferrer">See this article here</a></p>
<p>But in short, if you're using carbon, use the Gestalt() call, and if you're using cocoa, there is a constant called NSAppKitVersionNumber which you can simply check against.</p>
<p><em>Edit</em>: For... | <p><code>respondsToSelector:</code> almost certainly is better than you maintaining a table of what given releases do and do not implement. </p>
<p>Be lazy. Let the runtime tell you whether it can do something or not, and fall back to older methods when you need to. Your code will be far less fragile because you don't... | 19,075 |
<p>This is related to the <a href="https://stackoverflow.com/questions/24468/running-partially-trusted-net-assemblies-from-a-network-share">this question</a> and the answer maybe the same but
I'll ask anyways.</p>
<p>I understand that we can start managed executables from the network from .NET
3.5 SP1 but what about a... | <p>You have been able to load Assemblies from the network at leasst from .NET 2.0. I have used this on a previous project. The only thing to watch is the size of the assembly and the number and size of the dependancies that it is loading.</p>
<p>If you are using a seperate AppDomain, then you will need to take special... | <p>My understanding is yes, you're trying to load an untrusted module into your local app domain.</p>
| 8,616 |
<p>I recently came across a ASP 1.1 web application that put a whole heap of stuff in the session variable - including all the DB data objects and even the DB connection object. It ends up being huge. When the web session times out (four hours after the user has finished using the application) sometimes their database ... | <p>This is pretty hard to answer because it's so application-specific, but here are a few guidelines I use:</p>
<ol>
<li>Put as little as possible in the session.</li>
<li>User-specific selections that should only last during a given visit are a good choice</li>
<li>often, variables that need to be accessible to multi... | <p>A <a href="https://stackoverflow.com/questions/77826/php-session-what-are-the-pros-and-cons-of-storing-temporarily-used-data-in-the">very similar question</a> was asked regarding PHP sessions earlier. Basically, Sessions are a great place to store user-specific data that you need to access across several page loads... | 10,339 |
<p>I'm having a quite complex model with many fields, <code>has_many</code> associations, images added by <code>image_column</code> etc...</p>
<p>The New object will be added by a multi page form (8 steps) - How should I accomplish validation and propagation between those steps?</p>
<p>I think <code>validation_group<... | <p>For overall design, you might want to look into the concept of a Presenter layer (Jay Fields defines it in his blog entry <a href="http://blog.jayfields.com/2007/03/rails-presenter-pattern.html" rel="noreferrer">Rails: Presenter Pattern</a>) as a way to keep your controllers thin and views stupid when dealing with c... | <pre><code>class Campaign < ActiveRecord::Base
with_options(:if => lambda { |campaign| campaign.on_or_past_step(:spam_can) }) do |spam_can|
spam_can.validates_associated :spam_can
spam_can.validates_presence_of :spam_can
end
def on_or_past_step
:
:
end
end
</code></pre>
<p>this is ... | 24,489 |
<p>I got an Anet A8 and want to build an enclosure for it. Since I'm currently only printing PLA, I would do it mainly for noise cancelling, because I have to run it in my room. I however want to have the possibility to upgrade it later with, say, an air filter etc., for example for ABS.</p>
<ul>
<li>What do I have to... | <p>Sort of related, see the answers to:</p>
<ul>
<li><a href="https://3dprinting.stackexchange.com/questions/3771/commercially-available-3d-printer-fume-and-ufp-extractor">Commercially available 3D printer fume and UFP extractor</a>, and;</li>
<li><a href="https://3dprinting.stackexchange.com/questions/513/what-are-th... | <p>For ABS, if you are using an air filter, you do NOT want ventilation, because ABS prints are better quality if the ambient temperature is up at 50°C (or even warmer), and ventilation will reduce your chamber temperature. Whatever has been helping for noise cancelling now should work in the future.</p>
| 622 |
<p>I'm new to MVC (and ASP.Net routing). I'm trying to map <code>*.aspx</code> to a controller called <code>PageController</code>. </p>
<pre><code>routes.MapRoute(
"Page",
"{name}.aspx",
new { controller = "Page", action = "Index", id = "" }
);
</code></pre>
<p>Wouldn't the code above map *.aspx to <code>P... | <blockquote>
<p>I just answered my own question. I had
the routes backwards (Default was
above page).</p>
</blockquote>
<p>Yeah, you have to put all custom routes above the Default route.</p>
<blockquote>
<p>So this brings up the next question...
how does the "Default" route match (I
assume they use regul... | <p>Not sure how your controller looks, the error seems to be pointing to the fact that it can't find the controller. Did you inherit off of Controller after creating the PageController class? Is the PageController located in the Controllers directory?</p>
<p>Here is my route in the Global.asax.cs</p>
<pre><code>rou... | 3,304 |
<p>How can I to generate an RSS feed of Team Foundation Server commit messages?</p>
<p>In Visual Studio's Source Control Explorer, the "View History" option produces a nice GUI view. Likewise, the command line </p>
<pre><code>tf history /recursive /stopafter:40 .
</code></pre>
<p>produces a nice <em>GUI</em> view.... | <p><a href="http://blogs.msdn.com/abhinaba/archive/2005/12/21/506277.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/abhinaba/archive/2005/12/21/506277.aspx</a></p>
| <p><a href="http://blogs.msdn.com/abhinaba/archive/2005/12/21/506277.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/abhinaba/archive/2005/12/21/506277.aspx</a></p>
| 19,228 |
<p>I'm working on an application that makes extensive use of ComponentOne's C1FlexGrid. Of the dozens we use, three are missing their licenses.licx file and cause the demo splash screen to pop up while I'm starting the application.</p>
<p>Is there any way to determine which forms are causing this behavior. Short of ch... | <p>According to Microsoft documentation only the executable assembly requires a licenses.licx. Dll assemblies with forms in them will still create one but it is ignored. This has been my experience as well. I would suggest opening each form in the designer view and rebuilding while in that view. This will usually add a... | <p>Sometimes, opening forms and rebuilding whole solution even does not works. So in this situation. Just drag-drop some ComponentOne control from toolbox to your form (you may delete it afterwards). This drag-drop will generate licenses.licx automatically in Properties folder.</p>
| 24,822 |
<p>I've been Googling for quite awhile and haven't found a definitive answer. Is it possible to output a table using Apache POI? It looks like it hasn't been implemented, since the main developer stopped working on it like 5 years ago.</p>
<p>Is there an open source alternative to POI that can do this?</p>
| <p>I think you're right in that Apache POI is dead in the water. Clearly it wasn't glamourous enough.</p>
<p>The only alternative that I'm aware of is <a href="http://itextdocs.lowagie.com/tutorial/rtf/index.php" rel="nofollow noreferrer">iText</a>, which can generate RTF documents, which MS Word (and every other simi... | <p>If docx and java are both ok for you, try <a href="http://dev.plutext.org" rel="nofollow noreferrer">docx4j</a></p>
| 20,874 |
<p>From what I've read, <a href="http://blogs.msdn.com/astebner/archive/2008/08/11/8849574.aspx" rel="nofollow noreferrer">VS 2008 SP1 and Team Foundation Server SP1 packages are traditional service packs that require you to first install the original versions before you will be able to install the SP</a>.</p>
<p>Is t... | <p>Here's an <a href="https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3337363&SiteID=1" rel="nofollow noreferrer">MSDN forum post</a> in which an MSFTie indicates it will be possible and that details are forthcoming. Another poster is relaying results of her almost-successful attempt. Looks like this will ... | <p>::Copy some file to make slipstream integration successful. copy "VS2k8WithSP1\Program Files\Microsoft Visual Studio 9.0\Common7\1033*.chm" "VS2k8WithSP1\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\"</p>
<p>there is a error here, should be:</p>
<p>::Copy some file to make slipstream integration successfu... | 3,346 |
<p>I have two application. I need to do a single signon from application a to application b.</p>
<p>I thinking of using web service. I wonder how do i go about that approach.</p>
<p>Can anyone advise?</p>
| <p>Assuming these are web applications - you must implement some type of shared trust model between the applications.</p>
<p>Under no circumstance should you write your own. That is too easy to screw up and there are plenty of existing (both open and commercial) to choose from.</p>
<p>Here are following options:
1 - ... | <p>You could use an existing open source product, <a href="http://www.ja-sig.org/products/cas/" rel="nofollow noreferrer">CAS</a> and just implement it instead of develop your own. That way you'll be able to integrate with other applications that support the same protocol. Even if you decide to implement your own ins... | 45,051 |
<p>I have a goal to build an application with UI that would run on both Windows Mobile and "normal" desktop Windows. The priority is for it to "look good" under Windows Mobile, and for desktop Windows it is OK if it distorted. Before I invest days trying, I would like to hear if that is possible to begin with. There ar... | <ol>
<li>The CF <strong>contains</strong> a subset of the full framework (FFx), but it is not a pure subset. There are actually several things available in the CF that aren't in the FFx, which makes it a bit more difficult. CF apps also, except in the most rudimentary cases, use P/Invoke. Those calls are never the s... | <p>1). There is a Compact Framework so yes; And it is a subset of the full .NET framework. I've got a poster on my wall at the office that denotes a whole bunch of classes that work in CF... I don't recall off the top of my head if there are any that are purely CF, but I suppose there must be some. There are a couple... | 43,171 |
<p>Dear Stacktoverflow, can you show me an example of how to use a QScrollBar? Thanks.</p>
| <p>It will come down to you using the QScrollArea, it is a widget that implements showing something that is larger than the available space. You will not need to use QScrollBar directly. I don't have a PyQt example but there is a C++ example in the QT distribution it is called the "Image Viewer". The object hierarchy w... | <p>In the PyQT source code distribution, look at the file:</p>
<blockquote>
<p>examples/widgets/sliders.pyw</p>
</blockquote>
<p>Or there is a minimal example <a href="http://www.zetcode.com/tutorials/pyqt4/widgets/" rel="nofollow noreferrer">here</a> (I guess I shouldn't copy paste because of potential copyright i... | 16,824 |
<p>In Sql Server 2005 what data type should be used to store passwords <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha256managed(VS.71).aspx" rel="noreferrer">hashed by SHA-256 algorithm</a>? </p>
<p>The data is <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptogr... | <p>I prefer to convert the hash-Code to an Hex-String in this case a varchar(64) will do the trick or an varchar (66) if you like a "<code>0x</code>"-prefix. In this way it is much easier to compare manually or (re)set values you have to copy/paste from other places. e.g you lost your admin-PW and want to reset it via ... | <p>SHA-256 has a 256 bit output</p>
<p>256bits = 32 Bytes</p>
<p>So try varbinary(32)</p>
| 31,414 |
<p>Am I allowed to redistribute only parts of the DirectX package? (e.g. only the DirectDraw DLLs, without Show/3D/etc.)</p>
| <p>No. From the DirectX SDK Redist EULA:</p>
<blockquote>
<h2>DirectX Software Development Kit Redistributable Code</h2>
<p>Redistributable Code is identified as
all of the files in the following
"Redist" directory on the DirectX SDK
CD/Download:</p>
<p>redist/</p>
<p>The following files in the... | <p>The answer is "yes" and "no" depending on what eaxctly you are asking about. You are not able to ship any of the 'raw' DLLs in your app from the DirectX SDK, and you must make use of DirectSetup. You can, however, include only the CABs you actually need as discussed on <a href="http://msdn.microsoft.com/en-us/librar... | 33,262 |
<p>I have the requirement of generating UML Diagrams for one of my C++ assignments. I'm using Visio 2007 and I'm having trouble representing C++ vectors. The only way I can see this working is creating a custom C++ datatype or creating a vector class in my project, then for each instance of a vector in the UML, I need ... | <p>You don't need to stipulate that it's a vector on the UML diagram.</p>
<p>In the example you're giving, there is a one-to-many relationship between one class and another. That's the significant information you need to communicate.</p>
<p>You've chosen to implement this as a vector: this is an implementation detail... | <p>UML has a notation for parameterized classes. The parameter type goes into an overlapped box in the top right corner like <a href="http://www.csci.csusb.edu/dick/samples/uml.template.gif" rel="nofollow noreferrer">this</a> Whether your tools support it is another matter...</p>
| 29,537 |
<p>How do I go about setting a <code><div></code> in the center of the screen using jQuery?</p>
| <p>I like adding functions to jQuery so this function would help:</p>
<pre><code>jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) +
$(window).scrollTop()) + "px");
... | <p>Why you don't use CSS for centering a div?</p>
<pre><code>#timer_wrap{
position: fixed;
left: 50%;
top: 50%;
}
</code></pre>
| 25,869 |
<p>Given the following file:</p>
<pre><code>department=value1
location=valueA
location=valueB
department=value2
</code></pre>
<p>I use the following to load the file into a Perl hash:</p>
<pre><code>use File::Slurp;
use Data::Dumper;
my %hash = map {
s/#.*//;
s/^\s+//;
s/\s+$//;
m/(.*?)\s*=\s*(.*)/;
} re... | <p>Here you go:</p>
<pre><code>my %hash;
while (<FILE>)
{
chomp;
my ($key, $val) = split /=/;
$hash{$key} .= exists $hash{$key} ? ",$val" : $val;
}
</code></pre>
<p>This walks through every line splitting on the '=' sign and either adds an entry or appends to an existing entry in the hash table.</p>
| <p>Can you add some code to your map function to check for the existence of a hash entry and append the new value?</p>
<p>I haven't done Perl in a while, but when I did something like this in the past, I read the file in line by line (while $inputLine = <FILE>) and used split on '=' to load the hash with additio... | 29,147 |
<p>I need to setup an application that watches for files being created in a directory, both locally or on a network drive.</p>
<p>Would the <code>FileSystemWatcher</code> or polling on a timer would be the best option. I have used both methods in the past, but not extensively. </p>
<p>What issues (performance, reliab... | <p>I have seen the file system watcher fail in production and test environments. I now consider it a convenience, but I do not consider it reliable. My pattern has been to watch for changes with the files system watcher, but poll occasionally to catch missing file changes. </p>
<p>Edit: If you have a UI, you can al... | <p>I would say use polling, especially in a TDD scenario, as it is much easier to mock/stub the presence of files or otherwise when the polling event is triggered than to rely on the more "uncontrolled" fsw event. + to that having worked on a number of apps which were plagued by fsw errors.</p>
| 29,704 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.