instruction stringlengths 0 30k ⌀ |
|---|
|c++|nintendods|user-interface| |
I've made many different seperate parts of a GUI system for the Nintendo DS, like buttons and textboxes and select boxes, but I need a way of containing these classes in one Gui class, so that I can draw everything to the screen all at once, and check all the buttons at once to check if any are being pressed. My questi... |
|c++|user-interface| |
Java Time Zone is messed up |
|java|timezone| |
I am running a Tomcat application, and I need to display some time values. Unfortunately, the time is coming up an hour off. I looked into it and discovered that my default TimeZone is being set to:
sun.util.calendar.ZoneInfo[id="GMT-08:00",
offset=-28800000,dstSavings=0,useDaylight=false,
tr... |
I am running a Tomcat application, and I need to display some time values. Unfortunately, the time is coming up an hour off. I looked into it and discovered that my default TimeZone is being set to:
sun.util.calendar.ZoneInfo[id="GMT-08:00",
offset=-28800000,dstSavings=0,useDaylight=false,
tr... |
I am running a Tomcat application, and I need to display some time values. Unfortunately, the time is coming up an hour off. I looked into it and discovered that my default TimeZone is being set to:
sun.util.calendar.ZoneInfo[id="GMT-08:00",
offset=-28800000,dstSavings=0,useDaylight=false,
tr... |
There's many OS specific ways to force routing over specific interfaces. What OS are you using? XP? Vista? *nix?
The simplest way is to configure your network card with a static IP and NO GATEWAY, the only gateway (ie. internet access) your laptop will find is then via the mobile.
The disadvantage of this method ... |
Subversion, CVS and all other source control systems are not good for Word documents and other office files (such as Excel spread sheets), since the files themselves are stored in a binary format. That means that you can never go back and annotate (or blame, or whatever you want to call it), or do diffs between documen... |
Have you tried using [Monitor.Pulse](http://msdn.microsoft.com/en-us/library/system.threading.monitor.pulse.aspx) (ensure your thread is using thread management before running this) to get the thread to do something? If that works, then you're going to have to look a bit more into your threading logic. |
> We put the Thread.Sleep in after a couple of times when the database had gone away and we came back to 3Gb logs files full of database connection errors.
I would think a better option would be to make it so that your logging system trapped duplicates, so that it could write something like, "The previous message wa... |
Good question. These two operators work the same in PHP and C#.
| is a bitwise OR. It will compare two values by their bits. E.g. 1101 | 0010 = 1111. This is extremely useful when using bit options. E.g. Read = 01 (0X01) Write = 10 (0X02) Read-Write = 11 (0X03). One useful example would be opening files. A s... |
@Greg Hewgill
Amusingly, 'git checkout foo' will not work if the working copy is in a directory named foo; however, both 'git checkout HEAD foo' and 'git checkout ./foo' will:
$ pwd
/Users/aaron/Documents/work/foo
$ git checkout foo
D foo
Already on "foo"
$ git checkout ./foo
$ g... |
The single pipe, |, is one of the [bitwise][1] operators.
From Wikipedia:
> In the C programming language family, the bitwise OR operator is "|" (pipe). Again, this operator must not be confused with its Boolean "logical or" counterpart, which treats its operands as Boolean values, and is written "||" (two pipes).... |
TFS isn't just about Source Control. If you use the whole package that TFS offers, bug tracking, builds, reports, etc then TFS is a pretty solid choice (certainly better than Rational). TFS also integrates well with Active Directory.
Though if you are just talking about SCM, then I prefer SubVersion. I don't really ... |
I like stored procs, dont know how many times I was able to make a change to an application using a stored procedure which didn't produce any downtime to the application.
Big fan of Transact SQL, tuning large queries have proven to be very useful for me. Haven't wrote any inline SQL in about 6 years!
|
I did some googling and this is what I came up with:
<pre><code>
HttpContext.Current.Response.StatusCode = 401;
</code></pre>
Not sure if it works or not, I haven't tested it. Either way, it's worth a try, right? :) |
`cvs import` is not just for 3rd-party sources. In fact, directories are not versioned by CVS, so they are not a subject to branch policies. As long as you import empty directories, it is fine. |
By the way, you can expand on this idea to very quickly find _two_ unique numbers among a list of duplicates.
Let's call the unique numbers a and b. First take the XOR of everything, as Kyle suggested. What we get is a^b. We know a^b != 0, since a != b. Choose any 1 bit of a^b, and use that as a mask -- in more ... |
Use the global method std::remove with the begin and end iterator, and then use std::vector.erase to actually remove the elements.
Documentation links
std::remove http://www.cppreference.com/cppalgorithm/remove.html
std::vector.erase http://www.cppreference.com/cppvector/erase.html
std::vector<int> v;
... |
Use the global method std::remove with the begin and end iterator, and then use std::vector.erase to actually remove the elements.
Documentation links
std::remove http://www.cppreference.com/cppalgorithm/remove.html
std::vector.erase http://www.cppreference.com/cppvector/erase.html
std::vector<int> v;
... |
How do I install and use the ASP.NET AJAX Control Toolkit in my .NET 3.5 web applications? |
|asp.net|ajax|.net-3.5| |
How do I get it to work with my project?
[http://ajax.asp.net/][1]
[http://www.codeplex.com/AjaxControlToolkit/][2]
[1]: http://ajax.asp.net/
[2]: http://www.codeplex.com/AjaxControlToolkit/ |
>Hmmmm, I talking about them as they are implemented here:
>http://blog.benday.com/archive/2008/03/31/23176.aspx
>(at least Context.Handler there)
>I am still having trouble in VS making that reference.
Context.Handler is an instance of an HttpContext.
HttpContext exposes the CURRENT instance for the req... |
OK, if you're trying to update a row with ID = 1, you'll do it like this:
DataContext context = new DataContext();
LinqEntity item = (from le in context.LinqEntities
where le.ID == 1
select le).Single();
item.Name = "John";
item.Surname = "Doe";
... |
OK, if you're trying to update a row with ID = 1, you'll do it like this:
DataContext context = new DataContext();
LinqEntity item = (from le in context.LinqEntities
where le.ID == 1
select le).Single();
item.Name = "John";
item.Surname = "Doe";
... |
Use [Array.Copy][1]. It has an overload that does what you need:
> Array.Copy (Array, Int32, Array,
> Int32, Int32)
> *Copies a range of elements from an Array starting at the specified source
> index and pastes them to another Array
> starting at the specified destination
> index.*
[1]: http://msdn... |
[Array.Copy Method](http://msdn.microsoft.com/en-us/library/system.array.copy.aspx)
I guess something like:
string[] less = new string[parts.Length - (x - 2)];
Array.Copy(parts, x - 2, less, 0, less.Length);
(*sans* the off by 1 bug that I'm sure is in there.) |
Here's a nice add-on for Visual Studio 2005/2008 by Mikhail Arkhipov of MSFT. A 'smart' spell checker for ASP.NET and HTML pages - smart in the fact it can ignore the script and only focus on the text for spell checking.
* [Latest version][1]
[1]: http://blogs.msdn.com/webdevtools/archive/2007/12/13/spell-... |
Here's a nice add-on for Visual Studio 2005/2008 by Mikhail Arkhipov of MSFT.
* [Latest version][1]
[1]: http://blogs.msdn.com/webdevtools/archive/2007/12/13/spell-checker-for-html-asp-net-jscript-vb-c-css-and-c-for-visual-studio-2005-and-2008.aspx |
[FxCop ships with a spell check now][1] - have you tried that?
[Here's a nice add-on][2] for Visual Studio 2005/2008 by Mikhail Arkhipov of MSFT.
[1]: http://davesbox.com/archive/2008/06/08/fxcop-now-ships-with-the-spell-checker-libraries.aspx
[2]: http://blogs.msdn.com/webdevtools/archive/2007/12/13/spell-c... |
What's the best way to allow a user to browse for a file in C#? |
|c#| |
What's the best way to allow a user to browse for a file in C#? |
One specific reason static data is bad, is that C++ makes no guarantees about initialization order of static objects in different translation units. In practice this can cause problems when one object depends on another in a different translation unit. Scott Meyers discusses this in Item 26 of his book More Effective C... |
using (OpenFileDialog dlg = new OpenFileDialog())
{
dlg.Title = "Select a file";
if (dlg.ShowDialog()== DialogResult.OK)
{
//do something with dlg.FileName
}
} |
I would say use the standard "Open File" dialog box ([OpenFileDialog](http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx)), this makes it less intimidating for new users and helps with a consistant UI. |
Close, Ryan, but you never showed the dialog. it should be:
if (dlg.ShowDialog() == DialogResult.OK) |
@Juan Manuel Did you ever work in classic ASP? When you had to program all of your own events and "viewstatish" items (like a dropdown recalling its selected value after form submission)?
If so, then ASP.NET MVC will not feel that awkward off the bat. I would check out Rob Conery's Awesome Series "[MVC Storefront][1... |
Dynamic reference to resource files in C# |
|c#|localization| |
I have an application on which I am implementing localization.
I now need to dynamically reference a name in the resouce file.
assume I have a resource file called Login.resx, an a number of strings: foo="hello", bar="cruel" and baz="world"
normally, I will refer as:
String result =Login.foo;
and result=="h... |
Assuming you have an identity column in the table...
select
top 1 <fields>
from
HistoryTable
where
BatchRef = @BatchRef
order by
<IdentityColumn> DESC
|
I have a tendency to stick with basic integers at first (1,2,3), moving onto rational numbers (2.1, 3.13) when things get bigger...
Tried using fruit at one point, that works well for a small office. Oh, the 'banana' release? *looks over in the corner* "yea... thats getting pretty old now..."
Unfortunately confu... |
I maintain a system of web applications with various components that live in separate SVN repos. To be able to version track the system as a whole, I have another SVN repo which contains all other repos as external references. It also contains install / setup script(s) to deploy the whole thing. With that setup, the SV... |
It's a bit hard to decypher your data the way WMD has formatted it, but you can pull of the sort of trick you need with common table expressions on SQL 2005:
with LastBatches as (
select Batch, max(Id)
from HistoryTable
group by Batch
)
select *
from HistoryTable h
... |
How do I hide the input caret in a System.Windows.Forms.TextBox? |
|winforms|textbox| |
I need to display a variable-length message and allow the text to be selectable. The blinking input caret is confusing. How do I hide it? |
I need to display a variable-length message and allow the text to be selectable. I have made the TextBox ReadOnly which does not allow the text to be edited, but the input caret is still shown.
The blinking input caret is confusing. How do I hide it?
<hr>
[edit] First two answers are missing the primary questio... |
I need to display a variable-length message and allow the text to be selectable. I have made the TextBox ReadOnly which does not allow the text to be edited, but the input caret is still shown.
The blinking input caret is confusing. How do I hide it?
|
I wanted something similar, but with the ability to specify how the values on duplicate keys were merged, so I hacked this out (not heavily tested!). Obviously this is not a single expression, but it is a single fn. call.
def merge(d1, d2, merge=lambda x,y:y):
"""
Merges two dictionaries, non-... |
The main drawback of using ID, Name etc is that you have to qualify them with the table name if you are writing an SQL join which overlaps two tables.
Despite that, I find it far more concise and readable to just use ID and Name - your code and tables will 'flow' much more easily past the eyes. Easier to type and le... |
Tools to convert asp.net dynamic site into static site |
|asp.net|web-crawler| |
Are there any tools that will spider an asp.net website and create a static site? |
Unless I am misunderstanding you: you don't need to.
If you connect to the server with another application (ie: PuTTY) and it has not seen the server before then you will be prompted to accept the key.
I see why you might want to do this, but each application could have it's own way to store keys. |
This can also be the result of using reflection. If you have code that reflects on a class and extracts a method by name (eg: with `Class.getDeclaredMethod("someMethodName", .....)`) then any time that method name changes, such as during a refactor, you will need to remember to update the parameters to the reflection ... |
Did you write your own FormsAuth attribute for the action? If so, in the OnActionExecuting method, you get passed the FilterExecutingContext. You can use this to pass back the 401 code.
public class FormsAuth : ActionFilterAttribute
{
public override void OnActionExecuting(FilterExecutingContext ... |
Did you accidentally omit a semicolon on a previous line? If the previous line is an `#include`, you might have to look elsewhere for the missing semicolon. |
Did you accidentally omit a semicolon on a previous line? If the previous line is an `#include`, you might have to look elsewhere for the missing semicolon.
Edit: If the rest of your code is valid C++, then there probably isn't enough information to determine what the problem is. Perhaps you could post your code to ... |
> You can use Will Dean's suggestion [<code>#define arraysize(ar) (sizeof(ar) / sizeof(ar[0]))</code>] to replace the magic number 3 here with arraysize(str_array) -- although I remember there being some special case in which that particular version of arraysize might do Something Bad (sorry I can't remember the detai... |
Minimalistic Database Administration |
|database|administration|task| |
I am a developer. An architect on good days. Somehow I find myself also being the DBA for my small company. My background is fair in the DB arts but I have never been a full fledged DBA. My question is what do I have to do to ensure a realiable and reasonably functional database environment with as little actual ef... |
I've used [The Grinder][1]. It's open source, pretty easy to use, and very configurable. It is Java based and uses Jython for the scripts. We ran it against a .NET web application, so don't think it's a Java only tool (by their nature, any web stress tool should not be tied to the platform it uses).
We did some n... |
One more note, for our web application, I found that we had huge performance issues due to contention between threads over locks... so the moral was to think over the locking scheme very carefully. We ended up having worker threads to throttle too many requests using an asynchronous http handler, otherwise the applica... |
I have done a great deal of work handling bounce emails and there different types. If you want to be absolutely sure that the email your looking at is indeed a bounce of a specific kind I highly recommend getting a good filter. I have worked with [Boogie Tools][1] and it has worked very well. It lets you know what kind... |
We have been using [JSunit][1] for a while to do unit tests... it may not be the same kinds of tests you are talking about, but it is great for ensuring your JavaScript works as you expect.
You run it in the browser, and it can be set in an Ant build to be automatically run against a bunch of browsers on a bunch of ... |
Linq to objects - select first object |
|c#|linq|linq-to-objects| |
I know almost nothing about linq.
I'm doing this:
var apps = from app in Process.GetProcesses()
where app.ProcessName.Contains( "MyAppName" ) && app.MainWindowHandle != IntPtr.Zero
select app;
Which gets me all the running processes which match that criteria.
But I don't know how to get t... |
jQuery, action, return JSON.
<http://devlicio.us/blogs/mike_nichols/archive/2008/05/25/jquery-cascade-cascading-values-from-forms.aspx> |
Just to satisfy some curiosity:
From [Why doesn't C# support default parameters?][1]:
> In languages such as C++, a default value can be included as part of the method declaration:
> void Process(Employee employee, bool bonus = false)
> This method can be called either with:
> a.Process(employee, true);
... |
Exceptions in Web Services |
|.net|web-services|wcf|exception| |
My group is developing a service-based (.NET WCF) application and we're trying to decide how to handle exceptions in our internal services. Should we throw exceptions? Return exceptions serialized as XML? Just return an error code?
Keep in mind that the user will never see these exceptions, it's only for other pa... |
Well, there's always the low tech solution of adding logging of the size of your maps when you modify them, then search the logs for which maps are growing beyond a reasonable size. |
Reading from a http-get presenting in Firefox bookmarks |
|javascript|firefox|plugin-development|xul| |
I'm trying to get a Firefox plugin to read data from a HTTP get, parse the results and present them as links in a bookmark-like drop-down menu.
My quesion then is: Does anyone have any sample code that will do this?
|
Install Python to match directory layout in OS X 10.5 |
|python|macos|64-bit| |
The default Python install on OS X 10.5 is 2.5.1 with a fat 32 bit (Intel and PPC) client. I want to setup apache and mysql to run django. In the past I have run apache and mysql to match this install in 32 bit mode (even stripping out the 64 bit stuff from apache to make it work).
I want to upgrade Python to 64 bit... |
Thinking out of the box, would migrating to a Wiki be out of the question?
Since you consider it feasible to force your users into Subversion (or something similar), a larger change seem acceptable.
Another migration target could be to use some kind of structured XML document format ([DocBook](http://www.docbook.... |
You can try [GTK+][1]. I believe wxWidgets implementation for linux is written in GTK+.
[1]: http://www.gtk.org/ |
I tried Wireshark and Microsoft Network Monitor, but neither detected my (and the program I am trying to communicate with) transfer. If I had a day to sit and configure it I probably could get it working but I just wanted the bytes sent and, more specifically, bytes received.
In the end I found [HHD Software's Accur... |
As already suggested you probably want to reorder your query to sort it in the other direction so you actually fetch the first row. Then you'd probably want to use something like
SELECT TOP 1 ...
if you're using MSSQL 2k or earlier, or the SQL compliant variant
SELECT * FROM (
SELECT
R... |
It's kind of hard to make sense of your table design - I think SO ate your delimiters.
The basic way of handling this is to GROUP BY your fixed fields, and select a MAX (or MIN) for some unqiue value (a datetime usually works well). In your case, I *think* that the GROUP BY would be BatchRef and ItemCount, and Id wi... |
Watch out with that quote-matching lookahead assertion. That'll only match if *Boolean* is the last part of a string, but not in the middle of the string. You'll need to match an even number of quote marks preceding the match if you want to be sure you're not in a string (assuming no multi-line strings and no escaped e... |
How is your structure type defined? There are two ways to do it:
// This will define a typedef for S1, in both C and in C++
typedef struct {
int data;
int text;
} S1;
// This will define a typedef for S2 ONLY in C++, will create error in C.
struct S2 {
int dat... |
I rather like this new (?) behavior because the XML document doesn't have any mention of Bar in it, so the deserializer should not even be attempting to set it. |
Big fan of the UPSERT, really cuts down on the code to manage. Here is another way I do it: One of the input parameters is ID, if the ID is NULL or 0, you know it's an INSERT, otherwise it's an update. Assumes the application knows if there is an ID, so wont work in all situations, but will cut the executes in half ... |
I've used Red Gate's SQL Packager for this in the past. The beauty of this tool is that it creates a C# project for you that actually does the work so if you need to you can extend the functionality of the default package to do other things like insert default values into new columns that have been added to the db etc... |
If you have to use Rail's built-in Javascript generation, I would use Orion's solution, but with one small alteration to compensate for the return code.
eval ('function(){' + code + '}()');
However, in my opinion you'd have an easier time in the long run by separating out the Javascript code into an external... |
If you have to use Rail's built-in Javascript generation, I would use Orion's solution, but with one small alteration to compensate for the return code.
eval ('(function(){' + code + '})()');
However, in my opinion you'd have an easier time in the long run by separating out the Javascript code into an extern... |
I would suggest:
- A script to quickly restore the latest backup of a database, in case it gets corrupted
- What kind of backups are you doing? Full backups each day, or incremental every hour, etc?
- Some scripts to create new users and grant them basic access.
However, the number one suggestion is to l... |
@Juan Manuel Did you ever work in classic ASP? When you had to program all of your own events and "viewstatish" items (like a dropdown recalling its selected value after form submission)?
If so, then ASP.NET MVC will not feel that awkward off the bat. I would check out Rob Conery's Awesome Series "[MVC Storefront][1... |