instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p><a href="http://www.djangoproject.com/" rel="noreferrer">Django</a> view points to a function, which can be a problem if you want to change only a bit of functionality. Yes, I could have million keyword arguments and even more if statements in the function, but I was thinking more of an object oriented approach.</p>... | <p>I've created and used my own generic view classes, defining <strong><code>__call__</code></strong> so an instance of the class is callable. I really like it; while Django's generic views allow some customization through keyword arguments, OO generic views (if their behavior is split into a number of separate method... | <p>Sounds to me like you're trying to combine things that shouldn't be combined. If you need to do different processing in your view depending on if it's a User or Group object you're trying to look at then you should use two different view functions.</p>
<p>On the other hand there can be common idioms you'd want to ... | 2,315 |
<p>I have a update method in my data layer such this:</p>
<pre><code>public clacc datalayerSec_User
private objUIData as new UIData
Public Function Update(ByVal objUser As SEC_USER) As Boolean
Try
objUIData.SEC_USERs.Attach(objUser)
objUIData.Refresh(RefreshMode.KeepCurrentValues, objUser)
objUIData.Subm... | <p>The easiest way to get around this issue is to use the same DataContext when retrieving the user object and updating.</p>
<p>In general, a DataContext should be kept alive for a "unit of work", in other words, you use it to retrieve whatever object you want to change, then change its properties, and then just do Su... | <p>I dont know the answer to you question, and I have been stuck with the same issue too, but I adopted a simple strategy to prevent these little issues.</p>
<p>Instead of trying to attach/detach, fetch the actual object as soon as possible; this works quite well in web scenario's.</p>
| 47,468 |
<p>I want to select the topmost element in a document that has a given namespace (prefix).</p>
<p>More specifically: I have XML documents that either start with /html/body (in the XHTML namespace) or with one of several elements in a particular namespace. I effectively want to strip out /html/body and just return the ... | <p>In XPath 2.0 and XQuery 1.0 you can test against the namespace prefix using the <a href="http://www.w3.org/TR/xquery-operators/#func-in-scope-prefixes" rel="noreferrer">in-scope-prefixes()</a> function in a predicate.
e.g.</p>
<pre><code>//*[in-scope-prefixes(.)='html']
</code></pre>
<p>If you cant use v2, in XPa... | <p>The XPath expression that I want is:</p>
<pre><code>/html:html/html:body/node()|/foo:*
</code></pre>
<p>Where the "html" prefix is mapped to the XHTML namespace, and the "foo" prefix is mapped to my target namespace.</p>
| 13,764 |
<p>I've written a control that inherits from the <code>System.Web.UI.WebControls.DropDownList</code> and so I don't have any code in front for this control, but I still want to set the OutputCache directive. I there any way to set this in the C# code, say with an attribute or something like that? </p>
<p>I'm particu... | <p>I realize this is an incredibly old question but it is still worthy of an answer.</p>
<p>What you are talking about isn't a User Control it is a Custom Control. What you want to do with the OutputCache can be done simply with the Context Cache.</p>
<p>In your code where you are getting the data and binding to you... | <pre><code>Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Server);
Response.Cache.SetValidUntilExpires(true);
</code></pre>
| 10,439 |
<p>I'm using HTTPService with a POST operation to submit a Base64 encoded file (taken from bitmap data within the app) but I could really do with getting some idea of the progress of the POST operation (e.g. like the FileReference.upload()).</p>
<p>I don't think this is possible, but it would be awesome if it is (via ... | <p>Do not use HTTPService. Use URLRequest, URLLoader, and URLVariables.</p>
<p>If your using an HTTPService tag, get ride of it and replace it with a Script tag filled with something like ...</p>
<pre><code>
private function forYou() : void{
var req : URLRequest = new URLRequest("PUT YOUR URL HERE")
var loa... | <p>This worked well for me to consume a REST web service:</p>
<p><a href="http://code.google.com/p/as3httpclient/wiki/Links" rel="nofollow noreferrer">http://code.google.com/p/as3httpclient/wiki/Links</a></p>
<p><a href="http://www.abdulqabiz.com/blog/archives/flash_and_actionscript/http_authentica.php" rel="nofollow... | 49,515 |
<p>If anyone has experience using Oracle text (<code>CTXSYS.CONTEXT</code>), I'm wondering how to handle user input when the user wants to search for names that may contain an apostrophe.</p>
<p>Escaping the ' seems to work in some cases, but not for 's at the end of the word - s is in the list of stop words, and so s... | <p>Escape all special characters with backslashes. Curly braces won't work with substring searches as they define complete tokens. Eg %{ello}% won't match the token 'Hello' </p>
<p>Escaped space characters will be included in the search token, so the search string '%stay\ near\ me%' will be treated as a literal strin... | <p>Forget about sanitizing. Why? Refer to <a href="http://en.wikipedia.org/wiki/SQL_injection" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/SQL_injection</a> .</p>
<p>It depends on the kind of database interface API you are using. Perl DBI, ODBC, JDBC support parameterized queries or prepared statements. If ... | 27,019 |
<p>I have read the GOLD Homepage ( <a href="http://www.devincook.com/goldparser/" rel="nofollow noreferrer">http://www.devincook.com/goldparser/</a> ) docs, FAQ and Wikipedia to find out what practical application there could possibly be for GOLD. I was thinking along the lines of having a programming language (easily)... | <p>Parsing really consists of two phases. The first is "lexing", which convert the raw strings of character in to something that the program can more readily understand (commonly called tokens).</p>
<p>Simple example, lex would convert:</p>
<p>if (a + b > 2) then</p>
<p>In to: </p>
<pre>
IF_TOKEN LEFT_PAREN IDENTIF... | <p>GOLD can be used for any kind of application where you have to apply context-free grammars to input.</p>
<p>elaboration:</p>
<p>Essentially, CFGs apply to all programming languages. So if you wanted to develop a scripting language for your company, you'd need to write a parser- or get a parsing program. Alternativ... | 26,082 |
<p>I recently read this Question about <a href="https://stackoverflow.com/questions/3630/sqlite-vs-mysql">SQLite vs MySQL</a> and the answer pointed out that SQLite doesn't scale well and the official website <a href="http://www.sqlite.org/whentouse.html" rel="noreferrer">sort-of confirms this</a>, however.</p>
<p>How... | <p>Yesterday I released a small site<sup>*</sup> to track your rep that used a shared SQLite database for all visitors. Unfortunately, even with the modest load that it put on my host it ran quite slowly. This is because the entire database was locked every time someone viewed the page because it contained updates/inse... | <p>SQLite's website (the part that you referenced) indicates that it can be used for a variety of multi-user situations.</p>
<p>I would say that it can handle quite a bit. In my experience it has always been very fast. Of course, you need to index your tables and when coding against it, you need to make sure you use... | 7,870 |
<p>What is the best way of creating an alphabetically sorted list in Python?</p>
| <p>Basic answer:</p>
<pre><code>mylist = ["b", "C", "A"]
mylist.sort()
</code></pre>
<p>This modifies your original list (i.e. sorts in-place). To get a sorted copy of the list, without changing the original, use the <a href="http://docs.python.org/library/functions.html#sorted" rel="noreferrer"><code>sorted()</code>... | <p>Suppose <code>s = "ZWzaAd"</code> </p>
<p>To sort above string the simple solution will be below one.</p>
<pre><code>print ''.join(sorted(s))
</code></pre>
| 5,683 |
<p>In multi-threaded code, when an instance may be read or written by multiple threads, they need to be locked on to perform these operations safely.</p>
<p>To avoid the repetition of creating an object to lock on and writing a bunch of lock statements through code, I've created a generic class to handle the locking. ... | <p>That only locks for the duration of the get/set; of course, in many common cases this will be atomic anyway, simply due to to data size.</p>
<p>However, in reality most locks need to span more than this, in the same way that collections locking over just the Add etc don't help much - a caller typically needs a sing... | <p>Your code above has quite a few potential and real multi-threading issues, and I wouldn't use something like it in a real-world situation. For example:</p>
<pre><code>this.runningThreads.Set(this.runningThreads.Get() + 1);
</code></pre>
<p>There is a pretty obvious race condition here. When the <code>Get()</code> ... | 20,695 |
<p>What I'm doing is I have a full-screen form, with no title bar, and consequently lacks the minimize/maximize/close buttons found in the upper-right hand corner. I'm wanting to replace that functionality with a keyboard short-cut and a context menu item, but I can't seem to find an event to trigger to minimize the fo... | <pre><code>private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == 'm')
this.WindowState = FormWindowState.Minimized;
}
</code></pre>
| <pre><code>this.MdiParent.WindowState = FormWindowState.Minimized;
</code></pre>
| 9,475 |
<p>I'm working on a code base in which we have several configurable types. One of those types is 64 bit integer. When we compile for platforms that have no native 64 bit integer type, we simple represent 64 bit integers using a struct similar to</p>
<pre><code>typedef struct {
unsigned int hi, lo;
} int64;
</code>... | <p>Do you really need the cast? gcc is compiling the following example without any complains:</p>
<pre><code>
typedef struct int64 int64;
struct int64
{
unsigned int hi, lo;
};
typedef int64 mytime;
int64
add_int64(int64 a, int64 b)
{
int64 c;
/* I know that is wrong */
c.hi = a.hi + b.hi;
c.lo ... | <p>Right, so I'm using typedefs and no casting. Works fine. Seems strange though that an explicit cast doesn't compile while an implicit one does. If the implicit cast really isn't a cast at all since the compiler sees the two types as being the same type, one would think the same reasoning would work when doing an exp... | 33,615 |
<p>I don't see what all this fuss is about Microsoft's decision to support JQuery within ASP.NET MVC.</p>
<p>There were signs that open-minded people are starting to have some say in the matters of marketing for a while now. And even the way MS does business has started to change. But at it's core it's still acting in... | <p>Its the first time MS is shipping an open source component <em>they didn't write</em> with one of their products. This doesn't seem like a big deal, but its almost nuclear in its implications.</p>
<p>Think about it... They are saying "we support this." In an OSS product, MS has no control over the code. So, they... | <p>Bear in mind that Jquery is released by MS under the MIT license. This means, assuming I understand the terms of the MIT license correctly, that they could in future alter jquery arbitarily and close it off, presumably after its mass acceptance as part of Visual Studio.</p>
<p>Edit:
OK, I'm being modded down. Can s... | 17,908 |
<p>Classic ASP had 'server side includes' so that one could easily design a generic layout for the header, footer, left or right side bar.</p>
<p>In ASP.NET, I think we must use 'Page Templates'. Although most people say that it is easy to use, I find it rather complicated, as we must copy the whole HTML code inside t... | <p>I would have thought Master Pages were the standard approach in ASP.NET (2.0 and later). </p>
<ol>
<li>Design the master page in the
designer.</li>
<li>Designate the content area
or areas within this master page. </li>
<li>Then simply design separate
"content" pages and indicate the original master page
in the Pa... | <p>Master Pages and User Controls combine to give you way more power than ASP includes did.</p>
| 23,535 |
<p>I want to print a structure that I can embed in a resin and later dissolve. I know that some fancy 3D printing systems have raft materials etc., that can be printed and later removed easily. </p>
<p>Can any one suggest a 3D printing material that can be dissolved in say water or another readily available solvent?</... | <p>Wash-away filament used for support in PLA printing is typically PVA, which is completely water soluble and may serve your purpose. It is easily 3D printed as the primary filament and attaches well to the build plate.</p>
<p>Many 3D printer filament suppliers will carry this type of support material. It is importan... | <p>ABS dissolves in acetone. Indeed actone can be used to clean up 3D prints, see <a href="https://3dprinting.stackexchange.com/questions/4235/whats-smoother-acetone-treated-pla-or-abs/">What's smoother? Acetone treated PLA or ABS</a>. PLA maybe not somuch as ABS, see the same post.</p>
<p>PLA dissolves in any chl... | 910 |
<p>I have a unit test where I have statically defined a quite large byte array (over 8000 bytes) as the byte data of a file I don't want to read every time I run my unit test.</p>
<pre><code>private static final byte[] FILE_DATA = new byte[] {
12,-2,123,................
}
</code></pre>
<p>This compiles fine within Ec... | <p>Methods in Java are restricted to 64k in the byte code. Static initializations are done in a single method (see <a href="http://www.mail-archive.com/help-bison@gnu.org/msg01990.html" rel="noreferrer">link</a>)
<br/>
You may try to load the array data from a file.</p>
| <p>You can load the byte array from a file in you <code>@BeforeClass</code> static method. This will make sure it's loaded only once for all your unit tests.</p>
| 30,110 |
<p>High performance polymers are becoming available for specific applications.</p>
<p>One of such materials is PEEK (<a href="https://en.wikipedia.org/wiki/Polyether_ether_ketone" rel="noreferrer">PolyEther Ether Ketone</a>), a thermoplastic polymer in the polyaryletherketone (PAEK) family. PEEK competes with certain ... | <p>My assumptions about PEEK filament price are:</p>
<ul>
<li>Raw material is more expensive. Compare price of <a href="https://www.alibaba.com/showroom/abs-pellet.html" rel="noreferrer">ABS</a> with <a href="https://www.alibaba.com/showroom/peek-pellet.html" rel="noreferrer">PEEK</a> pellets.</li>
<li>Demand is much ... | <p><strong>Patents</strong> still seem to play a role as well.</p>
<p>I was curious about this question and did a bit of research: If you filter the <a href="https://patents.google.com/?q=%22Polyether%20ether%20ketone%22&country=US&after=priority:20100101" rel="noreferrer">U.S. patents after 2010 mentioning PE... | 979 |
<p>I have a lot of assignments where I have to continually update a Makefile as I add more subsequently numbered C programs. Is there a way to do this with a loop which iterates over the values 1.1, 1.2, 1.3, etc.?</p>
<pre><code>all: 1.1 1.2 1.3 1.4 1.5 1.6 1.7. 1.8 1.9
1.1: 1.1.o
gcc -o 1.1 $(FLAGS) 1.1.o
1.1.... | <p>You want a <a href="http://owen.sj.ca.us/rkowen/howto/slides/make/slides/makesuff.html" rel="nofollow noreferrer">suffix rule</a>, not a loop.</p>
| <p>Yes; you can use shell commands in a Makefile, and make itself may offer the looping you need. There are oodles of good examples all over the web; assuming from your use of <code>gcc</code> that you're also using GNU make, try here:</p>
<p><a href="http://www.gnu.org/software/make/manual/make.html#Foreach-Function... | 34,921 |
<p>I was just reading this <a href="https://stackoverflow.com/questions/243082/c-casting-programmatically-can-it-be-done">thread</a> and it occurred to me that there is one seemingly-valid use of that pattern the OP is asking about. I know I've used it before to implement dynamic creation of objects. As far as I know... | <p>I think what you are asking is how to keep the object creation code with the objects themselves.</p>
<p>This is usually what I do. It assumes that there is some key that gives you a type (int tag, string, etc). I make a class that has a map of key to factory functions, and a registration function that takes a key... | <p>Read the classic <a href="https://rads.stackoverflow.com/amzn/click/com/0201633612" rel="nofollow noreferrer" rel="nofollow noreferrer">Gang Of Four aka GOF</a>.
Consider [this site[(<a href="http://www.dofactory.com/Patterns/PatternAbstract.aspx" rel="nofollow noreferrer">http://www.dofactory.com/Patterns/PatternAb... | 30,150 |
<p>I'm working on a .Net application which uses Asp.net 3.5 and Lucene.Net I am showing search results given by Lucene.Net in an asp.net datagrid. I need to implement Paging (10 records on each page) for this aspx page.</p>
<p>How do I get this done using Lucene.Net?</p>
| <p>Here is a way to build a simple list matching a specific page with Lucene.Net. This is not ASP.Net specific.</p>
<pre><code>int first = 0, last = 9; // TODO: Set first and last to correct values according to page number and size
Searcher searcher = new IndexSearcher(YourIndexFolder);
Query query = BuildQuery(); // ... | <p>What I do is iterate through the hits and insert them into a temporary table in the db. Then I can run a regular SQL query - joining that temp table with other tables too - and give the grid the DataSet/DataView that it wants.</p>
<p>Note that I do the inserts and the query in ONE TRIP to the db, because I'm usin... | 41,342 |
<p>I'm trying to get NAnt 0.86b1 running with VS2008 SP1 and x64 XP.</p>
<p>I have a basic build file (below) which gives the error
Solution format of file 'Solution.sln' is not supported.</p>
<p>
</p>
<pre><code><property name="nant.settings.currentframework" value="net-3.5" />
<target name="build" descr... | <p>You'll notice that the docs indicate that NAnt's <a href="http://nant.sourceforge.net/release/0.85/help/tasks/solution.html" rel="noreferrer"><code><solution</code>></a> task doesn't support solution files newer than VS2003. </p>
<p>I recommend using <a href="http://nantcontrib.sourceforge.net/release/0.85/help/... | <p>See <a href="https://stackoverflow.com/questions/426199/building-the-platform-code-with-nant-and-vs2008/543648#543648">Building the platform code with nant and VS2008</a></p>
<p>This is here on Stack overflow. Basically you only have a couple of options, control all the builds yourself with project build files, co... | 42,480 |
<p>When you take your first look at an Oracle database, one of the first questions is often "where's the alert log?". Grid Control can tell you, but its often not available in the environment.</p>
<p>I posted some bash and Perl scripts to find and tail the alert log <a href="http://tardate.blogspot.com/2007/04/find-an... | <p>Am sure it will work in 11g, that parameter has been around for a long time.</p>
<p>Seems like the correct way to find it to me.</p>
<p>If the background_dump_dest parameter isn't set, the alert.log will be put in $ORACLE_HOME/RDBMS/trace</p>
| <p>Once you've got the log open, I would consider using <a href="http://search.cpan.org/perldoc?File::Tail" rel="nofollow noreferrer">File::Tail</a> or <a href="http://search.cpan.org/perldoc?File::Tail::App" rel="nofollow noreferrer">File::Tail::App</a> to display it as it's being written, rather than sleeping and rea... | 20,721 |
<p>I've read some of the recent language vs. language questions with interest... <a href="https://stackoverflow.com/questions/150043/python-v-perl#150103">Perl vs. Python</a>, <a href="https://stackoverflow.com/questions/136977/after-c-python-or-java#137343">Python vs. Java</a>, <a href="https://stackoverflow.com/quest... | <p>I hate Hate HATE "End Function" and "End IF" and "If... Then" parts of VB. I would much rather see a curly bracket instead.</p>
| <p>I have a practical one from years of code revewing and debugging other people's code. I would remove (from all languages) the ability to group logical operations in a conditional statement. This comes from a specific gripe about the AND operator e.g...</p>
<pre><code>if (a and b)
{
do something
}
</code></pre>
... | 19,455 |
<p><strong>Good day.</strong></p>
<p>I have a program thats launches an external application. That external app has a right click sub menu on it which I need to disable. Is it possible (without modifying the external app) to disable the right click? Maybe permission or group policies and etc.</p>
<p>Thanks.</p>
| <p>I wasn't sure I wanted to post as I don't have a huge amount of scope on the matter, but it's definatley possible.
If you have a handle to the application (if not you can get one) you can use that to disable right click within the application.</p>
<p><a href="http://www.codeguru.com/forum/showthread.php?t=190440" r... | <p>It's a win32 api FAQ.</p>
<p>see news://194.177.96.26/comp.os.ms-windows.programmer.win32
where it has often been discussed</p>
| 20,925 |
<p>There has been a flurry of updates released to Microsoft's Silverlight over the past couple of months (Silverlight 2 beta 2 runtime + dev tools, RC0 + dev tools which broke beta 2 apps), and recently Microsoft has released the RTM.</p>
<p>I have been trying (unsuccessfully) to integrate Sharepoint 2007 and Silverli... | <p>I haven't tried this out but
it seems like a good start:</p>
<p><a href="http://www.codeplex.com/SL4SP" rel="nofollow noreferrer">Silverlight Blueprint for SharePoint</a></p>
| <p>If you are going to be using User Controls [i.e. Web Parts], then I'd highly recommend looking at SmartPart. You'll still need to do the things in the blogs above to get the assemblies recognized, trusted, etc, but this may help you get your user controls deployed faster.</p>
| 32,373 |
<p>Is it good practice to let abstract classes define instance variables?</p>
<pre><code>public abstract class ExternalScript extends Script {
String source;
public abstract void setSource(String file);
public abstract String getSource();
}
</code></pre>
<p>The sub class, ExternalJavaScript.class, woul... | <p>I would have thought that something like this would be much better, since you're adding a variable, so why not restrict access and make it cleaner? Your getter/setters should do what they say on the tin.</p>
<pre><code>public abstract class ExternalScript extends Script {
private String source;
public voi... | <p>Of course. The whole idea of abstract classes is that they can contain some behaviour or data which you require all sub-classes to contain. Think of the simple example of WheeledVehicle - it should have a numWheels member variable. You want all sub classes to have this variable. Remember that abstract classes a... | 29,232 |
<p>I am using YUI reset/base, after the reset it sets the <code>ul</code> and <code>li</code> tags to list-style: disc outside;</p>
<p>My markup looks like this:</p>
<pre><code><div id="nav">
<ul class="links">
<li><a href="">Testing</a></li>
</ul>
</di... | <p>I think that Dan was close with his answer, but this isn't an issue of specificity. <strong>You can set the list-style on the list (the UL) but you can also override that list-style for individual list items (the LIs).</strong></p>
<p>You are telling the browser to not use bullets on the list, but YUI tells the br... | <p>Maybe the style is the base.css overrides your styles with "!important"? Did you try to add a class to this specific li and make an own style for it?</p>
| 13,332 |
<p>If I have two dates (ex. <code>'8/18/2008'</code> and <code>'9/26/2008'</code>), what is the best way to get the number of days between these two dates?</p>
| <p>If you have two date objects, you can just subtract them, which computes a <a href="https://docs.python.org/3/library/datetime.html#datetime.timedelta" rel="noreferrer"><code>timedelta</code></a> object.</p>
<pre><code>from datetime import date
d0 = date(2008, 8, 18)
d1 = date(2008, 9, 26)
delta = d1 - d0
print(de... | <p>Without using datetime object in python.</p>
<pre><code># A date has day 'd', month 'm' and year 'y'
class Date:
def __init__(self, d, m, y):
self.d = d
self.m = m
self.y = y
# To store number of days in all months from
# January to Dec.
monthDays = [31, 28, 31, 30, 31, 30... | 18,225 |
<p>I have several "ASP:TextBox" controls on a form (about 20).<br>
When the form loads, the text boxes are populated from a database.<br>
The user can change the populated values, and when they submit the form, I take the values posted to the server and conditionally save them (determined by some business logic).<br>
A... | <p>Are you initially loading the data only when !Page.IsPostBack? Also, is view state enabled for the text box?</p>
| <p>Remember the order of the page lifecycle, and where you are databinding your form.</p>
<ul>
<li>PreInit</li>
<li>Init</li>
<li>Load</li>
<li>Your Control Event Handler</li>
</ul>
<p>If you are reading the value in the Control Event handler, yet databinding in Init or Load, you'll have the old value.</p>
<p>The tr... | 4,299 |
<p>I found <a href="http://forums.mysql.com/read.php?100,22967,22967" rel="noreferrer">a posting on the MySQL forums from 2005</a>, but nothing more recent than that. Based on that, it's not possible. But a lot can change in 3-4 years.</p>
<p>What I'm looking for is a way to have an index over a view but have the tabl... | <p>I don't think MySQL supports materialized views which is what you would need, but it wouldn't help you in this situation anyway. Whether the index is on the view or on the underlying table, it would need to be written and updated at some point during an update of the underlying table, so it would still cause the wri... | <p>Do you only want one indexed view? It's unlikely that writing to a table with only one index would be that disruptive. Is there no primary key?</p>
<p>If each record is large, you might improve performance by figuring out how to shorten it. Or shorten the length of the index you need.</p>
<p>If this is a write-onl... | 30,278 |
<p>I'm trying to deserialize an xml structure that looks like this:</p>
<pre><code><somecontainer>
<key1>Value1</key1>
<key1>Value2</key1>
<key2>Value3</key2>
<key2>Value4</key2>
</somecontainer>
</code></pre>
<p>I can basically choose what k... | <p>Edit (Aug. 2012):</p>
<p>It turns out that currently the best solution are probably Guava 13.0's <code>Cache</code> classes, explained on <a href="https://github.com/google/guava/wiki/CachesExplained" rel="nofollow noreferrer">Guava's Wiki</a> - that's what I'm going to use.
It even supports building a <code>SoftHas... | <p>If you want to implement a cache softreferences are definetly a better idea than weak references, but it puts your entire cache removal policy in the hands of the garbage collector. which is probably not what you want.</p>
<p>If cache removal policy is important your are going to need to do it on your own most lik... | 33,147 |
<p>Need to show a credits screen where I want to acknowledge the many contributors to my application. </p>
<p>Want it to be an automatically scrolling box, much like the credits roll at the end of the film.</p>
| <p>A easy-to-use snippet would be to make a multiline textbox. With a timer you may insert line after line and scroll to the end after that:</p>
<pre><code>textbox1.SelectionStart = textbox1.Text.Length;
textbox1.ScrollToCaret();
textbox1.Refresh();
</code></pre>
<p>Not the best method but it's simple and working. Th... | <p>A quick and dirty method would be to use a Panel with a long list of Label controls on it that list out the various people and contributions. Then you need to set the Panel to be AutoScroll so that it has a vertical scrollbar because the list of labels goes past the bottom of the displayed Panel. Then add a time tha... | 8,847 |
<p>Here's what I need to do, any ideas would be helpful.</p>
<p>I need to be able to change the Local IP address of a computer programmatically as a limited user in XP. Without giving Admin information to the users. I've played with runas, sanur, and autoit, but all either require giving up the Administrator passwor... | <p>You should probably create a service that has administrative rights and allow limited users to request an IP change from that service.</p>
| <p>I'd imagine you could simply call <a href="http://msdn.microsoft.com/en-us/library/aa378184(VS.85).aspx" rel="nofollow noreferrer">LogonUser</a> with admin credentials, and change it from there. That'd require embedding the password in the EXE, of course.</p>
| 23,394 |
<pre><code>include("conn.php");
$result = mysql_query("SELECT * FROM sggame");
while($row = mysql_fetch_assoc($result));
{
$id = $row['id'];
echo $id;
echo 'working?';
}
</code></pre>
<p>The above code simply doesn't return anything out of the db. The row name is correct and the loop runs, showing that th... | <p>replace</p>
<pre><code>while($row = mysql_fetch_assoc($result));
</code></pre>
<p>with </p>
<pre><code>while($row = mysql_fetch_assoc($result))
</code></pre>
| <p>did this code give off a notice or warning when you where running it ? I am just curious being that the problem was the semicolon.</p>
| 46,806 |
<p>Why is it not advisable to use JavaScript in JSP? One rationale that I can think of is turning off the feature in browser would stop the code from executing. Is there any other reason behind this?</p>
| <p>Afaik, there is no problem in using javascript in jsp, and many sites do use it. Especially if your site is a web app, you <i>will</i> have to use both side by side. They are completely independent. You just have to make sure that what you are using each for is appropriate.</p>
<p><p>As for the part about turning o... | <p>JSP is a server side technology. That is - Server parses/compiles all the information and then sends it to the client (i.e. your browser). And then..</p>
<p>If received data contains ANY javascript then browser interprets it in its own javascript VM and server is long forgotten by then since HTTP is stateless proto... | 42,413 |
<p>I've always handled optional parameters in JavaScript like this:</p>
<pre><code>function myFunc(requiredArg, optionalArg){
optionalArg = optionalArg || 'defaultValue';
// Do stuff
}
</code></pre>
<p>Is there a better way to do it?</p>
<p>Are there any cases where using <code>||</code> like that is going to f... | <p>Your logic fails if optionalArg is passed, but evaluates as false - try this as an alternative</p>
<pre><code>if (typeof optionalArg === 'undefined') { optionalArg = 'default'; }
</code></pre>
<p>Or an alternative idiom:</p>
<pre><code>optionalArg = (typeof optionalArg === 'undefined') ? 'default' : optionalArg;
... | <p>I suggest you to use <a href="https://github.com/zvictor/ArgueJs" rel="nofollow">ArgueJS</a> this way:</p>
<pre><code>function myFunc(){
arguments = __({requiredArg: undefined, optionalArg: [undefined: 'defaultValue'})
//do stuff, using arguments.requiredArg and arguments.optionalArg
// to access your arg... | 17,942 |
<p>I'm making a C program where I need to get the directory that the program is started from. This program is written for UNIX computers. I've been looking at <code>opendir()</code> and <code>telldir()</code>, but <code>telldir()</code> returns a <code>off_t (long int)</code>, so it really doesn't help me. </p>
<p>Ho... | <p>Have you had a look at <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html" rel="noreferrer"><code>getcwd()</code></a>?</p>
<pre><code>#include <unistd.h>
char *getcwd(char *buf, size_t size);
</code></pre>
<p>Simple example:</p>
<pre><code>#include <unistd.h>
#include <stdi... | <p>Use <b>getcwd</b></p>
<pre><code>#include <stdio.h> /* defines FILENAME_MAX */
//#define WINDOWS /* uncomment this line to use it for windows.*/
#ifdef WINDOWS
#include <direct.h>
#define GetCurrentDir _getcwd
#else
#include <unistd.h>
#define GetCurrentDir getcwd
#endif
int main(){
char bu... | 38,214 |
<p>How do you feel about VS making you hunt for a tab that you used just minutes ago when you have a bazillion open tabs? What about constantly dragging tabs around to keep the ones you use close together?</p>
<p>Oh, so you think <em>AARGH</em>, too? Then read on.</p>
<p>I work on a piece of software with dozens of p... | <p>ReSharper and its Recent Files feature works a lot better for me.</p>
| <p>Control-Tab and the ">of" trick are both useful. Neither of them quite work for me, though, especially when I've got a lot of open files or I want quicker access.</p>
<p>I like the free <a href="http://www.usysware.com/dpack/" rel="nofollow noreferrer">DPack</a> collection of tools. There's a lot of neat stuff in... | 38,359 |
<p>I am using VMware Server 1.0.7 on Windows XP SP3 at the moment to test software in virtual machines.</p>
<p>I have also tried Microsoft Virtual PC (do not remeber the version, could be 2004 or 2007) and VMware was way faster at the time.</p>
<p>I have heard of Parallels and VirtualBox but I did not have the time t... | <p>Use <code>/dev/random</code> (requires user input, eg mouse movements) or <code>/dev/urandom</code>. The latter has an entropy pool and doesn't require any user input unless the pool is empty.</p>
<p>You can read from the pool like this:</p>
<pre><code>char buf[100];
FILE *fp;
if (fp = fopen("/dev/urandom", "r"))... | <p>The <code>/dev/random</code> device is intended to be a source of cryptographically secure bits.</p>
| 14,622 |
<p>I've had a little search and I was wondering if there is back compatibility for the .NET framework.</p>
<p>The real question is, if there's a program that uses .NET Framework 1.1, can I install 3.5 and be done, or do I have to install 1.1 and then if something uses 3.5 I have to install 3.5 as well?</p>
| <p>Unfortunately you will have to install both versions. Older version of the framework are not automatically bundled with newer versions.</p>
| <p>If you install something that requires 3.5, then you will have to install it. The way that .Net works though, you can have 1.1, 2.x and 3.5 all installed at the same time. Programs specify the version of the framework they need, and that version is loaded for them.</p>
| 9,744 |
<p>The last cross platform desktop development I did was Java/Swing. What about flex?</p>
| <p>Don't do it. If you need to go cross-platform, write the main guts of your application in a business logic layer that doesn't depend on any GUI framework and then use the native platform API to finish each app.</p>
<p>Your users will thank you.</p>
| <p>C# with Framework .Net can be good not only for Windows but for <a href="http://www.mono-project.com/Main_Page" rel="nofollow noreferrer">Linux with Mono</a>.</p>
<p>Microsoft have a <a href="http://www.microsoft.com/downloads/details.aspx?familyid=3a1c93fa-7462-47d0-8e56-8dd34c6292f0&displaylang=en" rel="nofol... | 22,936 |
<p>It seems that a List object cannot be stored in a List variable in C#, and can't even be explicitly cast that way.</p>
<pre><code>List<string> sl = new List<string>();
List<object> ol;
ol = sl;
</code></pre>
<p>results in Cannot implicitly convert type <code>System.Collections.Generic.List<str... | <p>Think of it this way, if you were to do such a cast, and then add an object of type Foo to the list, the list of strings is no longer consistent. If you were to iterate the first reference, you would get a class cast exception because once you hit the Foo instance, the Foo could not be converted to string!</p>
<p>... | <p>Here is another pre-.NET 3.5 solution for any IList whose contents can be cast implicitly.</p>
<pre><code>public IList<B> ConvertIList<D, B>(IList<D> list) where D : B
{
List<B> newList = new List<B>();
foreach (D item in list)
{
newList.Add(item);
}
retur... | 2,827 |
<p>All,</p>
<p>I have built a nifty demo application that displays data about our internal systems as a full-screen "billboard" style display. You could think of this as something like an application displaying the national deficit - rapidly increasing numbers, animating very quickly, all day.</p>
<p>The problem is t... | <p>I think you are looking for the Clutter Toolkit. It's free, cool, and multi-platform. Works on top of OpenGL by implementing all those timers and stuff you can't be arsed to implement yourself, and wrapping them on a very convenient and awesome API.</p>
<p><a href="http://clutter-project.org/" rel="nofollow norefer... | <p>SDL is an excellent toolkit to work with. If you already understand the principles of "plain old DirectDraw or OpenGL," you should have no trouble with SDL. I haven't seen every graphics framework out there, but of the ones I have seen, I'd definitely recommend SDL. It's designed by experienced game programmers w... | 20,837 |
<p>I inherited an application which uses a java properties file to define configuration parameters such as database name. </p>
<p>There is a class called MyAppProps that looks like this:</p>
<pre><code>public class MyAppProps {
protected static final String PROP_FILENAME = "myapp.properties";
protected static... | <p>If I make my own wrapper class like this; I always prefer to make strongly typed getters for the values, instead of exposing all the inner workings through the static final variables.</p>
<pre><code>private static final String DATABASE_NAME = "database_name"
private static final String DATABASE_USER = "database_use... | <p>You can use either, a static block or a constructor. The only advice I have is to use ResourceBundle, instead. That might better suit your requirement. For more please follow the link below.</p>
<p><strong>Edit:</strong>
<a href="http://www.russellbeattie.com/notebook/1007850.html" rel="nofollow noreferrer">Resourc... | 49,332 |
<p>It's great to find all those little snippets of code on the Web for your current needs, but is there anything better than getting whole application source code at once and reading it like a book?
There's no better way to learn positive and negative aspects of various architecture solutions.</p>
<p>That's why I was... | <p>Wikipedia's source code (MediaWiki) can be found at <a href="http://www.mediawiki.org/" rel="nofollow noreferrer">http://www.mediawiki.org/</a></p>
<p>The most relevant parts are</p>
<ul>
<li><a href="http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/" rel="nofollow noreferrer">"phase3"</a> (the core code; th... | <p>Check out Rob Conery's screencast series, <a href="http://blog.wekeroad.com/mvc-storefront/" rel="nofollow noreferrer">MVC Storefront</a>, where he builds a small commerce website using ASP.NET MVC.</p>
| 29,666 |
<p>We're currently using WinCVS but it's slow and has no merge dialog. I'm looking for something like Eclipse's Team Synchronize (so people can see what they'll get before they update).</p>
<p>What do you suggest? <a href="http://www.tortoisecvs.org/" rel="noreferrer">TortoiseCVS</a> with <a href="http://winmerge.org/... | <p>On windows, definitely using Tortoise CVS and WinMerge will meet your needs. I also think it would be a good idea to learn how to do some operations with the command line too. </p>
| <p>I was also searching for this currently. I got my eye on WinCVS and I liked it. but for my java projects I prefer eclipse which fulfills all my needs.. </p>
<p>edit.. my bad.. didnt see the date :(</p>
| 38,248 |
<p>Some examples I found that apparently worked with older versions of mvc suggest that there was a length parameter of sorts:</p>
<pre><code><%=Html.TextBox("test", 50)%>
</code></pre>
<p>But that may have been mistakenly setting the value.</p>
<p>How do this work in the current release? Passing in the style ... | <p>The original answer is no longer working as written:</p>
<pre><code><%=Html.TextBox("test", new { style="width:50px" })%>
</code></pre>
<p>will get you a text box with "{ style="width:50px" }" as its text content.</p>
<p>To adjust this for the current release of MVC 1.0, use the following script (note the ... | <p>new { style="width:50px", maxsize = 50 };</p>
<p>should be</p>
<p>new { style="width:50px", maxlength = 50 };</p>
| 42,041 |
<p>I need to be able to allow a user to enter Vietnamese text into a text box.</p>
<p>I have been instructed to use VNI-Times and provided a sample word document with Vietnamese text.</p>
<p>When I paste the text from the sample document into the textbox it is encoded incorrectly. I have tried installing the font (VN... | <p>The Asian Language Pack needed to be installed on the server (Windows Server 2003).</p>
<p>Once the server was migrated to Windows Server 2008 installing the VNI-Times font was sufficient to solve this problem.</p>
<p>This has also allowed the images to be generated properly.</p>
| <p>The problem is related to copying text with the clipboard. When you copy text from a text file in non-Unicode to a textbox that assumes Unicode, there is no encoding translation and the byte string is viewed incorrectly. Would you have used a keyboard to enter the Vietnamese text directly in the input controls (asp:... | 44,270 |
<p>I know this is a long shot - but is there any way at all to get code folding into Delphi 7?</p>
<p>I'm working on some .. "suboptimal" .. code. Sometimes I really need to fold bits away to grok a stupid-long procedure. Currently I'm pasting code into Notepad++, which works, but it would be nice to have it in the ID... | <p>Look for "method folding" on this <a href="http://www.gexperts.org/faq.html" rel="noreferrer">FAQ</a> (for GExperts) and you'll see that even this team, which has added many enhancements to Delphi, doesn't think this is in the cards for Delphi 7. I've looked for solutions and haven't seen them.</p>
| <p>As already mentioned, you could use the include file. But personally I don't like the idea of removing parts of code to another file, especially parts of a procedure (if I interpret your question the right way). I would prefer using bookmarks to rapidly navigate through the procedure, skipping the irrelevant parts, ... | 23,041 |
<p>I use int.MaxValue as a penalty and sometimes I am computing the penalties together. Is there a function or how would you create one with the most grace and efficiency that does that. </p>
<p>ie. </p>
<p>50 + 100 = 150</p>
<p>int.Max + 50 = int.Max and not int.Min + 50 </p>
| <pre><code>int penaltySum(int a, int b)
{
return (int.MaxValue - a < b) ? int.MaxValue : a + b;
}
</code></pre>
<p>Update: If your penalties can be negative, this would be more appropriate:</p>
<pre><code>int penaltySum(int a, int b)
{
if (a > 0 && b > 0)
{
return (int.MaxValue - ... | <p>Does it overflow a lot, or is that an error condition? How about using try/catch (overflow exception)?</p>
| 15,861 |
<p>I read somewhere that NTP is based on UDP and there's no security built with NTP communication so it is easy to spoof NTP responses. Is it true? Wouldn't that be a major security issue since most of the servers out there depend on NTP to sync their clock?</p>
| <p>here is an <a href="http://securityvulns.com/advisories/timesync.asp" rel="nofollow noreferrer">interesting article</a> that talks about some of the security concerns, it might be a bit dated, but a good read.</p>
| <p>Yes, it is relatively easy and there are multiple exploits currently available. Most important to realize it that larger enterprises Sync NTP Timing through GPS, typically located within secure facilities. This minimizes the effectiveness of remote attacks. Therefore, the exploits and "hacking" causes more damage to... | 30,992 |
<p>I am considering to apply Entity Framework in a new project because I liked its OR/M-API as well as the storage/conceptual model mapping-capabilities (plus Linq of course and Entity SQL).</p>
<p>But how can loose coupling be achieved betwen the UI layer and the business layer if EF entities are used as dataholders ... | <p>"Replaying" the changes is easier than you might think. Here's the general outline of what you need to do:</p>
<ol>
<li>Store the "original" version of the entity instance before you detach it and hand it to the UI.</li>
<li>Let the UI do its thing.</li>
<li>When you want to persist changes made by the UI to the d... | <p>Google "Entity framework" and "vote of no confidence" and see what you get.</p>
| 10,886 |
<p>I am starting a WPF project, which will be fairly complicated in complexity and will make use of a lot of modern UIs, like outlook bar, grids, tabs, etc... I've looked around in the marketplace and there aren't too many control suites. Some of the available ones are either Beta or CTP. Others don't look too polis... | <p>The thing to remember is that WPF is very different from WinForms, you can do amazing things buy just re-skining existing controls, when you are starting your first WPF big project you don't yet understand WPF and you don't know the possibilities and pitfalls of the system.</p>
<p>I suggest you start developing the... | <p>I would say to take a look on what it is already in there. In my point of view I am pretty much covered with the available ones, and especially in .NET 4, where the DataGridView, Calendar, and DateTimePicker are included (finally).</p>
<p>But if you want also take a look in the components from a company named Infra... | 45,714 |
<p>I'm using WinRAR SFX module to create an installation, and use its presetup option to run some preliminary tests.</p>
<p>Since wscript can only accept vbs file, and not the script itself, I first run "cmd /c echo {...script code...} > setup.vbs", and then I run "wscript setup.vbs". The run of the first cmd command ... | <p>Is the script code already in a file? If so,</p>
<p>You can use the TYPE command to send the script to a file:</p>
<pre><code>TYPE [script_file] > setup.vbs
</code></pre>
<p>or COPY the script file:</p>
<pre><code>COPY [script_file] setup.vbs
</code></pre>
<p>If the script code is in the body of your <code>c... | <p>Rather than use <code>cmd /c echo {...script code...} > setup.vbs</code> as a presetup step, perhaps you could package a VBscript with your install that does your preliminary tests and creates <code>setup.vbs</code>, and then calls <code>setup.vbs</code> for you. You'd have to put this in the setup portion of the... | 48,502 |
<p>All I know about the constraint is it's name (<code>SYS_C003415</code>), but I want to see it's definition.</p>
| <p>Looks like I should be querying <code>ALL_CONSTRAINTS</code>.</p>
<pre><code>select OWNER, CONSTRAINT_NAME, CONSTRAINT_TYPE, TABLE_NAME, SEARCH_CONDITION from ALL_CONSTRAINTS where CONSTRAINT_NAME = 'SYS_C003415';
</code></pre>
| <p>Or to see all constaints use SYS.DBA_CONSTRAINTS (If you have the privileges)</p>
| 10,938 |
<p>We've got a webserver running IIS. We'd like to run maybe a shared blog or something to keep track of information. Because of security issues, we'd like for that part to be only viewable from localhost so people have to remote in to use it.</p>
<p>So, to repeat my question, can part of a website be made viewable fr... | <p>For some one doing it in <code>IIS 8</code> / <code>Windows 2012</code></p>
<p>1) In <code>Server Manager</code>, go to <code>Manage, Add Roles and Features</code>, Next, Next (get to <code>Server Roles</code>), scroll down to <code>Web Server (IIS)</code>, expand that row, then expand <code>Web Server</code>, and... | <p>You could simply add this .NET to the top of the page.</p>
<pre><code>string MyWebServerName = currentContext.Request.ServerVariables["SERVER_NAME"];
if ( MyWebServerName == "127.0.0.1" || MyWebServerName == "localhost" )
{
// the user is local
}
else
{
// the user is NOT local
}
</code></pre>
| 33,962 |
<p>I have a java object with several members. I want to create a small, quick and dirty editor that allows me to set the value of the members in an easy way. I've created a Panel that contains a TextField for every member. I have a setValues() method that will take the value of the TextFields and set them into the o... | <p>To answer your question directly, there is no such thing as a Intellij IDEA GUI WYSIWYG editor for GWT for the moment. </p>
<p>The most popular/feature complete WYSIWYG editor for GWT is <a href="http://www.instantiations.com/windowbuilder/" rel="noreferrer">Instantiations GWT Designer</a>. It is available only for... | <p>Unfortunately, there really isn't one yet. We're going to have to wait until 2016 when Google takes over the world; everything will be so much easier then! ;)</p>
| 46,669 |
<p>In the <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml" rel="noreferrer">Google C++ Style Guide</a>, the <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Operator_Overloading" rel="noreferrer">section on Operator Overloading</a> recommends against overloading <em>any</e... | <p>Except for the more fundamental types, the less-than operation isn't always trivial, and even equality may vary from situation to situation.</p>
<p>Imagine the situation of an airline that wants to assign all passengers a boarding number. This number reflects the boarding order (of course). Now, what determines who... | <p>Ironically, a functor also requires overriding an operator (the function call operator - <code>operator ()</code>), so I'm not sure what their point is.</p>
| 22,204 |
<p>I will explain problem with an example:</p>
<p>There is two table in my database, named entry, tags</p>
<p>There is a column named ID_ENTRY in both table. When I add a record to table, entry, I have to take the ID_ENTRY of last added record and add it to table, tags. How can I do it?</p>
| <p>The only way to do this is with multiple statements. Using dynamic sql you can do this by separating each statement in your query string with a semi-colon:</p>
<pre><code>"DECLARE @ID int;INSERT INTO [Entry] (...) VALUES ...; SELECT @ID = scope_identity();INSERT INTO [TAGS] (ID_ENTRY) VALUES (@ID);"
</code></pre>... | <p>I would probably do this with an INSERT trigger on the named entry table, if you have all of the data you need to push to the tags table available. If not, then you might want to consider using a stored procedure that creates both inside a transaction.</p>
<p>If you want to do it in code, you'll need to be more sp... | 40,664 |
<p>Let's say I have a source file with many preprocessor directives. Is it possible to see how it looks after the preprocessor is done with it?</p>
| <p><code>cl.exe</code>, the command line interface to Microsoft Visual C++, has three different options for outputting the preprocessed file (hence the inconsistency in the previous responses about Visual C++):</p>
<ul>
<li><code>/E</code>: <a href="http://msdn.microsoft.com/en-us/library/3xkfswhy.aspx" rel="noreferre... | <p><a href="http://cpip.sourceforge.net/" rel="nofollow noreferrer">CPIP</a> is a new C/C++ preprocessor written in Python. If you want a detailed visual representation of a preprocessed file, give it a shot.</p>
<blockquote>
<p>CPIP is a C/C++ pre-processor implemented in Python. Most pre-processors regard pre-process... | 34,986 |
<p>I picked up some no-name "silk" PLA in a multi color pack as part of a project where I needed some additional distinct colors and structural properties didn't matter, but now I'm playing with the excess I'm not using for that, and its behavior is really weird. On overhangs with detail on the downward-facin... | <p>It has additives to the PLA to change its characteristics.</p>
<blockquote>
<p>Typically, “silk” filaments are enhanced PLA filaments, owing their glossy result to various additives. As such, they tend to show most of the same pros and cons of PLA filament. In the case where silk filaments have a different base, the... | <p>It has additives to the PLA to change its characteristics.</p>
<blockquote>
<p>Typically, “silk” filaments are enhanced PLA filaments, owing their glossy result to various additives. As such, they tend to show most of the same pros and cons of PLA filament. In the case where silk filaments have a different base, the... | 1,942 |
<p>I use eclipse to work on an application which was originally created independently of eclipse. As such, the application's directory structure is decidedly not eclipse-friendly.</p>
<p>I want to programmatically generate a project for the application. The <code>.project</code> and <code>.classpath</code> files are... | <p>You should be able to accomplish this by writing a small Eclipse plugin. You could even extend it out to being a "headless" RCP app, and pass in the command line arguments you need.</p>
<p>The barebones code to create a project is:</p>
<pre><code>IProgressMonitor progressMonitor = new NullProgressMonitor();
IWork... | <p>To create java project you can use JavaCore from <code>org.eclipse.jdt.core.JavaCore</code>. As a <code>sourceProject</code> you can use generic project item, which has been suggested by @James Van Huis</p>
<pre class="lang-java prettyprint-override"><code>IJavaProject javaSourceProject = JavaCore.create(sourceProje... | 31,372 |
<p>I would like to throw an exception when my C++ methods encounter something weird and can't recover. Is it OK to throw a <code>std::string</code> pointer?</p>
<p>Here's what I was looking forward to doing:</p>
<pre><code>void Foo::Bar() {
if(!QueryPerformanceTimer(&m_baz)) {
throw new std::string("i... | <p>Yes. <a href="http://en.cppreference.com/w/cpp/error/exception" rel="noreferrer"><code>std::exception</code></a> is the base exception class in the C++ standard library. You may want to avoid using strings as exception classes because they themselves can throw an exception during use. If that happens, then where wi... | <p><strong>Simplest way to throw an Exception in C++:</strong></p>
<pre><code>#include <iostream>
using namespace std;
void purturb(){
throw "Cannot purturb at this time.";
}
int main() {
try{
purturb();
}
catch(const char* msg){
cout << "We caught a message: " << msg ... | 16,289 |
<p>I know there is a similar problem on this forum, but the solutions did not really work for me. I am populating form controls with fields from a few different data sources, and the data shows up great.</p>
<p>I have an <code>ImageButton</code> control, which has an <code>OnClick</code> Event set to grab all of the ... | <p>In EF, if you use this code, you have all the entities that are already loaded in the context (including newly added ones) :</p>
<pre><code>context.ObjectStateManager.GetObjectStateEntries(EntityState.Added | EntityState.Modified | EntityState.Unchanged).Select(o => o.Entity).OfType<YourObjectType>()
</cod... | <p>"The same question also applies to LinqToSql."</p>
<p>For LINQ-to-SQL, look at <a href="http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.getchangeset.aspx" rel="nofollow noreferrer"><code>DataContext.GetChangeSet()</code></a>; this has <a href="http://msdn.microsoft.com/en-us/library/system.data... | 42,259 |
<p>Lets say you have a:</p>
<pre><code>List<string> los = new List<string>();
</code></pre>
<p>In this crazy functional world we live in these days which one of these would be best for creating one string by concatenating these:</p>
<pre><code>String.Join(String.Empty, los.ToArray());
StringBuilder buil... | <p>I would go with option A:</p>
<pre><code>String.Join(String.Empty, los.ToArray());
</code></pre>
<p>My reasoning is because the Join method was written for that purpose. In fact if you look at Reflector, you'll see that unsafe code was used to really optimize it. The other two also WORK, but I think the Join funct... | <p>My vote is string.Join</p>
<p>No need for lambda evaluations and temporary functions to be created, fewer function calls, less stack pushing and popping.</p>
| 41,203 |
<p>I have been experimenting with <a href="http://www.woopra.com/" rel="nofollow noreferrer">woopra.com</a> A web analytics tool. Which requires a piece of javascript code to be added to each page to function. This is easy enough with more dynamic sites with universal headers or footers but not for totally static html ... | <p>I think that <a href="http://httpd.apache.org/docs/2.2/mod/mod_ext_filter.html" rel="nofollow noreferrer">mod_filter_ext</a> is the module you are looking for. You can write a short Perl script for example to insert the JS code in the pages and register it to process HTML pages:</p>
<pre><code>while (<>) {
... | <p>ok the method above's biggest problem is it would break your html validity by placing a script tag outside the <code><html></code> tags</p>
<p>i'd agree with the others on a pre-process run over your html files such as a sed/awk script</p>
<p>heres a quick example {assuming the script part can be added befor... | 6,136 |
<p>For example, how much memory is required to store a list of one million (32-bit) integers?</p>
<pre><code>alist = range(1000000) # or list(range(1000000)) in Python 3.0
</code></pre>
| <p>"It depends." Python allocates space for lists in such a way as to achieve <a href="http://effbot.org/zone/python-list.htm" rel="noreferrer">amortized constant time</a> for appending elements to the list.</p>
<p>In practice, what this means with the current implementation is... the list always has space allocated ... | <p>This is implementation specific, I'm pretty sure. Certainly it depends on the internal representation of integers - you can't assume they'll be stored as 32-bit since Python gives you arbitrarily large integers so perhaps small ints are stored more compactly. </p>
<p>On my Python (2.5.1 on Fedora 9 on core 2 duo) t... | 16,427 |
<p>Heres a screenshot to make it clear. I'm trying to figure out a robust way of making the bullet images vertically aligned to my li content. As you can see my content is currently too high.</p>
<p>Many thanks 'over-flowers'...</p>
<p><a href="http://dl.getdropbox.com/u/240752/list-example.gif" rel="nofollow norefer... | <p>Well, some css code to see how you currently set your bullet images would be useful ;-)</p>
<p>Instead of actually setting the 'list-style-image' property, I've had far more consistent results with setting a background-image property for the li element. You can then control the positioning with pixel accuracy. Reme... | <p>You can use something like this in your css...</p>
<pre><code>#content li{
list-style-image: url(../images/bullet.gif);
}
</code></pre>
| 26,778 |
<p>I had created the xml document with xml version="1.0".</p>
<p>In that document I need to use the greater than symbol <code>></code> and less than symbol <code><</code>.</p>
<p>How should I include those symbols? It's not working.</p>
<p><code>&gt;</code> and <code>&lt;</code> are not working for me.... | <p>You need the <a href="http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references" rel="noreferrer">Character Entity References</a></p>
<p><code>< = &lt;</code></p>
<p><code>> = &gt;</code></p>
| <p>Use <code>&gt;</code> and <code>&lt;</code> for 'greater-than' and 'less-than' respectively</p>
| 42,844 |
<p>I suppose this is a strange question to the huge majority of programmers that work daily with Java. I don't. I know Java-the-language, because I worked on Java projects, but not Java-the-world. I never made a web app from scratch in Java. If I have to do it with Python, Ruby, I know where to go (Django or Rails), bu... | <p>By far the best Clojure web framework I have yet encountered is Compojure: <a href="http://github.com/weavejester/compojure/tree/master" rel="noreferrer">http://github.com/weavejester/compojure/tree/master</a></p>
<p>It's small but powerful, and has beautifully elegant syntax. (It uses Jetty under the hood, but it ... | <p><a href="http://arachne-framework.org/" rel="nofollow noreferrer">Arachne</a> is a newcomer web framework.
Quoting the site's description:</p>
<blockquote>
<p>Arachne is a full, highly modular web development framework for
Clojure. It emphasizes ease, simplicity, and a solid, scalable
design.</p>
</blockquote... | 20,201 |
<p>I just re-ran all basic calibration steps from the Original Prusa i3 MK2 Manual.</p>
<p>Now, when doing the first layer calibration, lines that are running in positive X direction are ok, while those running in negative X direction are severely squished.</p>
<p><a href="https://i.stack.imgur.com/5zzEl.jpg" rel="no... | <h2>No FDM print at all.</h2>
<p>The problem of your design will not be the materials, but a basic property of FDM printing: FDM Printers do create a structure by placing a long string of filament next to itself and ontop of itself, creating tons of boudaries.</p>
<p>These boundaries between the layers are the weak poi... | <h2>No FDM print at all.</h2>
<p>The problem of your design will not be the materials, but a basic property of FDM printing: FDM Printers do create a structure by placing a long string of filament next to itself and ontop of itself, creating tons of boudaries.</p>
<p>These boundaries between the layers are the weak poi... | 942 |
<p>We use Sharepoint as CMS for our webpages at work. I know how to create controls that can be only visible if you have logged in in SharePoint with:</p>
<p><Sharepoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl1" runat="server" PermissionsString="AddAndCustomizePages">&... | <p>How are the users authenticated? With forms authentication or Windows/active directory?</p>
<p>If active directory, then I think in that case you might need to get a reference to the current SPWeb, and then do web.CurrentUser.ID. This might come out null when you are anonymous. If not, try web.SiteUsers.GetByID(web... | <p>Although I haven't tested it, I imagine the LoginName property of the SPUser object will be blank, or throw an exception.</p>
<p>... of course, its never safe to presume anything when dealing w/the SharePoint OM :(</p>
| 49,903 |
<p>First, I am Linq to Sql newbie, so please be gentle :).</p>
<p>I have existing ASP.Net application developed over last 3.5 years. It has pretty big data model underneath, around 350 tables. I am trying to do some new things with Linq to SQL. </p>
<p>First impression is that linq designer and SqlMetal are built for... | <p>well, my solution was to use SQLMetal's <code>/code</code> option to create plain classes in a .cs file instead of a DBML file, and use partial classes in a separate file to extend the generated ORM classes. </p>
<p>I know that doesn't solve your issue of splitting parts of your database into different ORM assembli... | <p>If I were you I would be using <a href="http://msdn.microsoft.com/en-us/library/bb399572.aspx" rel="nofollow noreferrer">Entity Framework</a> as this is the MS recommended ORM going forward <a href="http://ayende.com/Blog/archive/2008/10/31/microsoft-kills-linq-to-sql.aspx" rel="nofollow noreferrer">Microsoft kills ... | 34,651 |
<p>There are several application systems that pass messages to each other as part of their work process. Due to technical constraints revolving transactional integrity, the application data and message delivery are all committed into a single mainframe DB2 database. The messages are not directly passed to BizTalk serve... | <p>Chris is correct - it seems it's only the inner part of the message you actually care about, the outer part is just an envelope.</p>
<p>As such I would suggest you create a disassembler which, in the receive pipeline, will strip out the envelope (you can keep it in it's entirety as a context property and/or extract... | <p>I would suggest looking into envelope schemas to 'unwrap' the interior message from the outer message. I believe the envelope can promote properties from the envelope into the inner message's context as it moves through the receive pipeline. The inner message will then have to map to a schema of its own type. You... | 31,894 |
<p>The canonical way to return multiple values in languages that support it is often <a href="https://stackoverflow.com/questions/38508/whats-the-best-way-to-return-multiple-values-from-a-function-in-python">tupling</a>.</p>
<h3>Option: Using a tuple</h3>
<p>Consider this trivial example:</p>
<pre><code>def f(x):
y0 ... | <p><a href="http://docs.python.org/library/collections.html#namedtuple-factory-function-for-tuples-with-named-fields" rel="noreferrer">Named tuples</a> were added in 2.6 for this purpose. Also see <a href="http://docs.python.org/library/os.html#os.stat" rel="noreferrer">os.stat</a> for a similar builtin example.</p>
... | <p>In languages like Python, I would usually use a dictionary as it involves less overhead than creating a new class.</p>
<p>However, if I find myself constantly returning the same set of variables, then that probably involves a new class that I'll factor out.</p>
| 46,242 |
<p>I've used <a href="http://members.fortunecity.com/neshkov/dj.html" rel="noreferrer">DJ Java Decompiler</a>, which has a handy GUI, but it seems as if the latest version is only a trial and forces you to purchase the software after some period of days (I recall using an earlier free version about a year ago at a prev... | <p>JAD is one of the best Java Decompiler today. This is one brilliant piece of software. Nevertheless, the last JDK supported by JAD 1.5.8 (Apr 14, 2001) is JDK 1.3.</p>
<p>DJ Java Decompiler, JadClipse, Cavaj and JarInspector are powered by Jad.
The last version of Decafe Pro has been released on 2002-01-03.</p>
<... | <p>Many of these decompilers are based on Jad:</p>
<ul>
<li><a href="http://www.kpdus.com/jad.html" rel="nofollow noreferrer">http://www.kpdus.com/jad.html</a></li>
</ul>
<p>I like the JadClipse Eclipse plugin:</p>
<ul>
<li><a href="http://sourceforge.net/projects/jadclipse" rel="nofollow noreferrer">http://sourcefo... | 24,774 |
<p>What update rate should I run my fixed-rate game logic at?</p>
<p>I've used 60 updates per second in the past, but that's hard because it's not an even number of updates per second (16.666666). My current games uses 100, but that seems like overkill for most things.</p>
| <p>None of the above. For the smoothest gameplay possible, your game should be time-based, not frame-locked. Frame-locking works for simple games where you can tweak the logic and lock down the framerate. It doesn't do so well with modern 3D titles where the framerate jumps all over the board and the screen may not be ... | <p>Bear in mind that unless your code is measured down to the cycle, not each game loop will take the same number of milliseconds to complete - so 16.6666 being irrational is not an issue really as you will need to time and compensate anyway. Besides it's not 16.6666 updates per second, but the average number of millis... | 11,372 |
<p>Alright so I'm essentialyl trying to code something that will combine two files together in VB and output a single file that when run, runs both of them. I've grabbed this source from several places online and am just trying to get it to work. We have the main program that combines them with a GUI</p>
<pre><code>... | <p>One major issue is that you are using String variables which terminate at the first null character (ASCII code 0)</p>
<p>Since executable files are binary, it is exceptionally likely that they are are not being copied into (or out of) the file in full.</p>
<p>As a result, I would suggest reading the files into a B... | <p>I would start by comparing the temporary files, are you successfully re-writing out the files where they are exact matches to that of the source?</p>
| 26,184 |
<p>I want to write my own little chat server in C on a MacOS machine. Now I want to connect to all clients, that are online and let the connection open, to be able to receive and send messages. The problem is that I only know, how to have one socket connection at a time open. So only one client can connect so far and c... | <p>The simplest solution for a small chat server is probably to use select() or pselect().</p>
<p>Have a look at the excellent <a href="http://beej.us/guide/bgnet/" rel="nofollow noreferrer">Beej's Guide to Network Programming</a>. In his <a href="http://beej.us/guide/bgnet/output/html/multipage/advanced.html#select" ... | <p>Basically you need to have a listening socket on your chosen port. Once a connection is established to the listening socket, you need to open a new socket on a different port number and hand the client over to this new socket. It will be best to try and use a pre-written socket library as rolling your own here is go... | 44,607 |
<p>Given a week number, e.g. <code>date -u +%W</code>, how do you calculate the days in that week starting from Monday?</p>
<p>Example rfc-3339 output for week 40:</p>
<pre><code>2008-10-06
2008-10-07
2008-10-08
2008-10-09
2008-10-10
2008-10-11
2008-10-12
</code></pre>
| <p><strong>PHP</strong></p>
<pre><code>$week_number = 40;
$year = 2008;
for($day=1; $day<=7; $day++)
{
echo date('m/d/Y', strtotime($year."W".$week_number.$day))."\n";
}
</code></pre>
<p><hr>
Below post was because I was an idiot who didn't read the question properly, but will get the dates in a week starting ... | <pre><code> <?php
$iWeeksAgo = 5;// need weeks ago
$sWeekDayStartOn = 0;// 0 - Sunday, 1 - Monday, 2 - Tuesday
$aWeeksDetails = getWeekDetails($iWeeksAgo, $sWeekDayStartOn);
print_r($aWeeksDetails);
die('end of line of getWeekDetails ');
function getWeekDetails($iWeeksAgo, $sWeekDayStart... | 22,556 |
<p>Both <code>static_cast</code> and <code>reinterpret_cast</code> seem to work fine for casting <code>void*</code> to another pointer type. Is there a good reason to favor one over the other?</p>
| <p><strong>Use <code>static_cast</code></strong>: it is the narrowest cast that exactly describes what conversion is made here.</p>
<p>There’s a misconception that using <code>reinterpret_cast</code> would be a better match because it means “completely ignore type safety and just cast from A to B”.</p>
<p>However, th... | <p><code>reinterpret_cast</code> will forcefully convert the <code>void*</code> to the target data type. It doesn't guarantee any safety and your program might crash as the underlying object could be anything.</p>
<p>For ex, you could typecast an <code>myclass*</code> to <code>void*</code> and then use <code>reinterpr... | 39,998 |
<p>I have video that I've converted to FLV format. I'd rather host it on my own site than use a service like YouTube. What is the easiest player to use? I'd like to just put the .swf file of the player somewhere on my server, and give it the video as a parameter.</p>
| <p>Take a look at <a href="http://www.osflv.com/" rel="noreferrer">OSflv</a>.</p>
| <p>I have tried many FLV players and i came across Applian FLV Player. this one has got to be my best. it is light weight, its free comes with an optional audio recorder and no spyware or such. <a href="http://www.applian.com/flvplayer/" rel="nofollow noreferrer">check it out here</a></p>
<p>With this however you will... | 12,463 |
<p>I have a VBS script that currently writes to a logfile. This script can be kicked off my multiple simultaneous processes so now I'm worried about concurrency.</p>
<p>I'm currently using <code>FileSystemObject</code> to open and write to this file. Does FSO support exclusive file access?</p>
| <p>Yes, FileSystemObject does support exclusive file access. If another process has a lock on the file when you call OpenTextFile, you will get an error (a permission denied error). You should be able to trap the error and handle it appropriately (check that Err.Number <> 0 after the call to OpenTextFile is one way ... | <p>I don't know how accessable the Windows API is to you, but you should have a look at the Debugging infrastructure in the Windows API.</p>
<p>Theres a good Code Project article on it <a href="http://www.codeproject.com/KB/winsdk/OutputDebugString.aspx" rel="nofollow noreferrer">here</a>
Basically using OutputDebugSt... | 30,928 |
<p>How to query to get count of matching words in a field, specifically in MySQL.
simply i need to get how many times a "search terms"appear in the field value.</p>
<p>for example, the value is "one two one onetwo" so when i search for word "one" it should give me 3</p>
<p>is it possible? because currently i just ext... | <p>Are you looking to find a query that, given a list of words, returns the number of matching words in a database field?</p>
<p>eg:</p>
<p>Database table has</p>
<pre>
ID Terms
1 cat, dog, bird, horse
</pre>
<p>then running a check on the words "cat, horse" returns 2?</p>
<p>If so, I suggest you do your ch... | <p>I suggest that you do that outside SQL, no matter the engine, Regular Expressions are more suited for that than SQL Language. You could probably do that with a view or something but as I said, there are more proper ways to do it like the string manipulation class/object/function from your language or regular express... | 41,782 |
<p>A colleague and I have spent a few years developing a really cool Matlab application, MDLcompress. Within Matlab, I can type "MDLcompress('filename.txt')" and it will tell me all sorts of really cool stuff about the contents of filename.txt. We'd like to allow other people to use MDLcompress without downloading th... | <p>If you are mostly proficient in MATLAB you can write web application in MATLAB with <a href="http://www.mathworks.co.uk/access/helpdesk_r13/help/toolbox/webserver/ch01intr.html" rel="noreferrer">MATLAB Web Server</a>
<strong>Edit:</strong>
Matlab Web Server is discontinued, so it is not for you if you use recent ver... | <p>We have developed a toolbox called <a href="http://www.modelit.nl/index.php/matlab-products/modelit-matlab-webserver-toolbox" rel="nofollow noreferrer">Modelit Webserver Toolbox</a> that should allow you to do this. We use this ourselves to run a Routing algorithm implemented in Matlab for an online route planner (t... | 41,699 |
<p>I know I should be using htmlentities for all my form text input fields but this doesn't work:</p>
<pre><code><?php
echo "<tr>
<td align=\"right\">".Telephone." :</td>
<td><input type=\"text\" name=\"telephone\" size=\"27\"
value=\"htmlentities($row[tele... | <p>try using </p>
<pre><code>value=\"" . htmlentities($row[telephone]) . "\"
</code></pre>
<p>there. Currently, your string simply contains the htmlentities string and splices the variable in. You need to get out the string, call the function and put it's result in place, as above.</p>
| <p>First of all, don't echo your HTML in a string. Separate code from markup.</p>
<pre><code><tr>
<td align="right">Telephone :</td>
<td><input type="text" name="telephone" size="27"
value="<?php echo htmlentities($row['telephone']); ?>"> Inc. dialing codes</td>... | 25,678 |
<p>I've added a proxy to a webservice to a VS2008/.NET 3.5 solution. When constructing the client .NET throws this error:</p>
<blockquote>
<p>Could not find default endpoint element that references contract 'IMySOAPWebService' in the ServiceModel client configuration section. This might be because no configuaration ... | <p>"This error can arise if you are calling the service in a class library and calling the class library from another project."</p>
<p>In this case you will need to include the WS configuration settings into the main projects app.config if its a winapp or web.config if its a web app. This is the way to go even with PR... | <p>In my case, I was referring to this service from a library project, not a startup Project.
Once I copied <code><system.serviceModel></code> section to the configuration of the main startup project, The issue got resolved.</p>
<p>During running stage of any application, the configuration will be read from the ... | 45,928 |
<p>In a class diagram, is there a way of specifying that a class is an internal class of another class ? </p>
<p>Or is it considered as a pure implementation choice ? </p>
| <p>Consider using a nesting relationship (a line with a '+' in a circle at the parent end).</p>
| <p>Or you can show the inner class fully enclosed by the outer class, one rectangle inside another.</p>
| 29,762 |
<p>We need to see what methods/fields an object has in Javascript.</p>
| <p>As the others said, you can use Firebug, and that will sort you out no worries on Firefox. Chrome & Safari both have a built-in developer console which has an almost identical interface to Firebug's console, so your code should be portable across those browsers. For other browsers, there's <a href="http://getfir... | <p>The following is my favorite <strong>var_dump/print_r equivalent</strong> in Javascript to PHPs <code>var_dump</code>.</p>
<pre><code>function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;
//The padding given at the beginning of the line.
var level_padding = ""... | 41,877 |
<p>Is there an iSeries command to export the data in a table to CSV format?</p>
<p>I know about the Windows utilities, but since this needs to be run automatically I need to run this from a CL program.</p>
| <p>You can use CPYTOIMPF and specify the TOSTMF option to place a CSV file on the IFS.
Example:
CPYTOIMPF FROMFILE(DBFILE) TOSTMF('/outputfile.csv') STMFCODPAG(*PCASCII) RCDDLM(*CRLF)</p>
| <p>You are going to need FTP to perform that action.
If your iSeries shop uses ZMOD/FTP your shortest solution is a few lines of code away -- 3 lines to be exact -- the three lines are to Start FTP, Put DBF, and finally, End FTP.</p>
<p>IF you don't use ZMOD/FTP:
- You could use native FTP/400 to accomplish what you ... | 17,913 |
<p>For a load test of my application (under Linux), I'm looking for a tool that outputs data on stdout at a specific rate (like 100 bytes/s), so that I can pipe the output to netcat which sends it to my application. Some option for dd would be ideal, but I didn't find anything so far. It doesn't really matter what kind... | <p>I wrote a quick program that takes one argument, how many <code>A</code> characters to print to standard output per second (negative argument means no rate limiting). Hope this helps! :-) (On GNU libc, you will need to link your program with <code>-lrt</code>.)</p>
<p>Edit: revised to print dot by default, unless a... | <p>Well, I'm now using nuttcp to do "real" load tests instead. It seems to have quite low overhead, so the test system is not too much disturbed.</p>
| 30,052 |
<p>What is the difference between the scalar and list contexts in Perl and does this have any parallel in other languages such as Java or Javascript? </p>
| <p>Various operators in Perl are context sensitive and produce different results in list and scalar context.</p>
<p>For example:</p>
<pre><code>my(@array) = (1, 2, 4, 8, 16);
my($first) = @array;
my(@copy1) = @array;
my @copy2 = @array;
my $count = @array;
print "array: @array\n";
print "first: $first\n";
print "c... | <p>This simply means that a data-type will be evaluated based on the mode of the operation. For example, an assignment to a scalar means the right-side will be evaluated as a scalar.</p>
<p>I think the best means of understanding context is learning about wantarray. So imagine that = is a subroutine that implements wa... | 49,344 |
<p>What is the best way to find out whether two number ranges intersect?</p>
<p>My number range is <strong>3023-7430</strong>, now I want to test which of the following number ranges intersect with it: <3000, 3000-6000, 6000-8000, 8000-10000, >10000. The answer should be <strong>3000-6000</strong> and <strong>6000-... | <p>Just a pseudo code guess:</p>
<pre><code>Set<Range> determineIntersectedRanges(Range range, Set<Range> setofRangesToTest)
{
Set<Range> results;
foreach (rangeToTest in setofRangesToTest)
do
if (rangeToTest.end <range.start) continue; // skip this one, its below our range
if (range... | <p>If you're using Java
<a href="http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/math/Range.html#overlapsRange%28org.apache.commons.lang.math.Range%29" rel="nofollow">Commons Lang Range</a>
has a
overlapsRange(Range range) method.</p>
| 27,799 |
<p>I need to generate a new interface at run-time with all the same members as an existing interface, except that I will be putting different attributes on some of the methods (some of the attribute parameters are not known until run-time). How can it be achieved?</p>
| <p>Your question isn't very specific. If you update it with more information, I'll flesh out this answer with additional detail.</p>
<p>Here's an overview of the manual steps involved.</p>
<ol>
<li>Create an assembly with DefineDynamicAssembly</li>
<li>Create a module with DefineDynamicModule</li>
<li>Create the typ... | <p>Your question isn't very specific. If you update it with more information, I'll flesh out this answer with additional detail.</p>
<p>Here's an overview of the manual steps involved.</p>
<ol>
<li>Create an assembly with DefineDynamicAssembly</li>
<li>Create a module with DefineDynamicModule</li>
<li>Create the typ... | 16,522 |
<p>I've used Emacs for years on Linux, and I have lots of personally useful keybindings I've put under <kbd>Hyper</kbd> and <kbd>Super</kbd>. Nowadays I'm using Emacs on Windows and am missing those extra keybindings.</p>
<p>Is there some way in Windows to get modifier keys other than <kbd>Ctrl</kbd> and <kbd>Meta</kb... | <p>There are some settings mentioned in <a href="http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/93ee43478903f273" rel="noreferrer">this google-groups thread:</a></p>
<pre><code>; setting the PC keyboard's various keys to Super or Hyper
(setq w32-pass-lwindow-to-system nil
w32-pass-rwindow-to-... | <p>You may find this difficult, because Super (and, I believe, Hyper) are intercepted by the Windows Shell (explorer.exe) before they ever reach your app.</p>
| 46,515 |
<p>This is a follow-on question to the <a href="https://stackoverflow.com/questions/29061/how-do-you-use-ssh-in-a-shell-script">How do you use ssh in a shell script?</a> question. If I want to execute a command on the remote machine that runs in the background on that machine, how do I get the ssh command to return? ... | <p>I had this problem in a program I wrote a year ago -- turns out the answer is rather complicated. You'll need to use nohup as well as output redirection, as explained in the wikipedia artcle on <a href="http://en.wikipedia.org/wiki/Nohup" rel="noreferrer">nohup</a>, copied here for your convenience. </p>
<blockquot... | <p>First follow this procedure: </p>
<p>Log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:</p>
<pre><code>a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter pa... | 4,881 |
<p>Is there any way to force Text-Mate to use a two-space tab instead of a full tab when editing HTML (Rails) documents?</p>
| <p>Yes. There's a pop-up menu near the bottom middle of the window that probably reads <code>Tabs: 4</code> or something like that. Click on it and hange it to <code>2</code> and <code>Soft Tabs</code>.</p>
<p>You should have an <code>rhtml</code> or <code>erb</code> document (or whatever file type you want to change)... | <p>On the topic of tabs, these TextMate menu commands are also helpful: </p>
<ul>
<li>Text -> Convert -> Spaces to Tabs</li>
<li>Text -> Convert -> Tabs to Spaces</li>
</ul>
<p>Tabs to Spaces is very helpful for fixing tab-related errors when working in with <a href="http://haml.hamptoncatlin.com/" rel="nofollow nore... | 38,062 |
<p>I am having trouble constructing a single XPath statement to return two different sets of attributes. </p>
<p>For example take the following XML document:</p>
<pre><code><root>
<line name="one" alpha="a1" beta="b1"/>
<line name="two" alpha="a2" beta="b2"/>
<line name="three" alpha="a3" bet... | <p>By using the <code>|</code> operator in an XPath expression you can select several paths:</p>
<pre><code>//@alpha | //@beta
</code></pre>
| <pre><code>//@*[name()='alpha' or name()='beta']
</code></pre>
| 39,058 |
<p>That is, I'd like to have a tuple of values.</p>
<p>The use case on my mind:</p>
<pre><code>Dictionary<Pair<string, int>, object>
</code></pre>
<p>or</p>
<pre><code>Dictionary<Triple<string, int, int>, object>
</code></pre>
<p>Are there built-in types like Pair or Triple? Or what's the b... | <pre><code>public struct Pair<T1, T2>
{
public T1 First;
public T2 Second;
}
public struct Triple<T1, T2, T3>
{
public T1 First;
public T2 Second;
public T3 Third;
}
</code></pre>
| <p>There aren't built ins, but a Pair<T,R> class is trivial to create. </p>
| 12,733 |
<p>Right now we've got web pages that show UI elements, and web pages that just process form submissions, and then redirect back to the UI pages. They do this using PHP's header() function:</p>
<pre><code>header("Location: /other_page.php");
</code></pre>
<p>This causes a 302 Found response to be sent; according to ... | <p>You can use either, but the proper statuscode to use for redirect-after-post is 303.</p>
<p>The confusion has a historical explanation. Originally, 302 specified that the browser mustn't change the method of the redirected request. This makes it unfit for redirect-after-post, where you want the browser to issue a G... | <p>To expand on RoBorg's answer, many browsers do not understand more than a handful of the many, many HTTP response codes.</p>
<p>A side note: it you are at all concerned about search engine placement, 302s can (supposedly) cause problems.</p>
| 34,520 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.