instruction stringlengths 0 30k ⌀ |
|---|
The list uses this interface alot, so you can say a.Substract(b) or other of these nice functions.
Just remember: If you're objects don't return the same Hashcode, the Equals is not called. |
How to force a reboot instead of shutdown (XP) |
|windows|shutdown|reboot|restart| |
I have a Windows XP SP2 virtual machine which can be accessed via VNC. It's also running Deep Freeze so there should be no problem in forcing it to reboot. I am looking for a way to force the operating system to reboot instead of shutting down or completely remove the ability to shut down the machine using software app... |
There is no way to make it completely unhackable, as it is easy to decompile SWFs, and a skilled developer hacker could then trace through your code and work out how to bypass any encrypted system you might employ.
If you simply want to stop kids cheating via the use of simple tools like TamperData though, then you ... |
When I need to do paging, I typically use a temporary table as well. You can use an output parameter to return the total number of records. The case statements in the select allow you to sort the data on specific columns without needing to resort to dynamic SQL.
--Declaration--
--Variables
@St... |
Use the NET command:
To start a service, type: net startservice
To stop a service, type: net stopservice
To pause a service, type: net pauseservice
To resume a service, type: net continueservice
See this Microsoft article on additional details:
[Microsoft Article][1]
In addition I would look at the... |
While this *should* work, I don't think you can guarantee it to be safe because the SOME_STRUCT is not a char* (unless it's merely a typedef).
Additionally, since you're using different types of references, if you continue to use the *p access, and the memory has been deleted, you will get a runtime error. |
If you are looking for more XUnit-style testing, check out [Test::Class](http://search.cpan.org/perldoc?Test::Class). It provides the `Test(setup)` and `Test(teardown)` attributes for methods that, well, set up and tear down your environment. It also gives you a much nicer way of dealing with plans (you can provide one... |
Extracting text from a PDF using JBoss Richfaces |
|richfaces|ajax|seam|ria|java| |
I am trying to write a web-app to manage references for my PhD thesis.
I used to manage this information inside a personal Confluence (fantastic tool! - http://www.atlassian.com/software/confluence/) instance however I'm fed-up with the opening of PDF's and cutting and pasting values into fields that I wish to recor... |
|java|ajax|seam|ria|richfaces| |
I am trying to write a web-app to manage references for my PhD thesis.
I used to manage this information inside a personal Confluence (fantastic tool! - http://www.atlassian.com/software/confluence/) instance however I'm fed-up with the opening of PDF's and cutting and pasting values into fields that I wish to recor... |
|c++|visual-studio|c| |
The Visual Studio compiler does not seem to warn on signed/unsigned assignments, only on comparisons. For example the code below will generate a warning on the if statement but not the initial assignments.
Is there anyway to make it catch these? I'm already at W4 but thought (hoped) there may be another setting some... |
How do you do AppBar docking (to screen edge, like WinAmp) in WPF? |
|c#|wpf|appbar|dock|docking| |
Is there any complete guidance on doing AppBar docking (such as locking to the screen edge) in WPF? I understand there are InterOp calls that need to be made, but I'm looking for either a proof of concept based on a simple WPF form, or a componentized version that can be consumed.
Related resources:
- <http://w... |
Most people use symbols (that's the `:foo_bar` syntax). They're sort of unique opaque values. Symbols don't belong to any enum-style type so they're not really a faithful representation of C's enum type but this is pretty much as good as it gets. |
I've never come across a problem caused by using width, padding and/or margin together.
So long as you have a valid DOCTYPE and are not in Quirks Mode, you will have a predictable box model and therefor should use whichever is most appropriate out of margin/padding to represent what you are trying to do.
Note:
M... |
I use multiple buffers
set hidden in my vimrc
The mini-buffer explorer script is nice too to get a nice compact listing of your buffers. Then :b1 or :b2... to go to the appropriate buffer or use the mini-buffer explorer and tab through the buffers. |
You can cast the output of Convert:
EmployeeNumber = string.IsNullOrEmpty(employeeNumberTextBox.Text)
? null
: (int?)Convert.ToInt32(employeeNumberTextBox.Text)
|
I, like everyone else here, find that cascade deletes are really only marginally helpful (it's really not that much work to delete referenced data in other tables -- if there are lot of tables, you simply automate this with a script) but really annoying when someone accidentally cascade deletes some important data that... |
Should you really be processing things one-by-one? Shouldn't you just have SQL Server acknowledge all unacknowledged messages with todays date and return them? (all also in a transaction of course)
|
It's not a question of using AddHandler versus Handles.
If you are concerned about the reference to your event handler interfering with garbage collection, you should use RemoveHandler, regardless of how the handler was attached. In the form or control's Dispose method, remove any handlers.
I have had situations... |
@Kilhoffer:
The whole SQL batch is parsed before execution, so SQL knows that you're going to do an update to the table as well as select from it.
Edit: Also, SQL will not necessarily lock the whole table - it could just lock the necessary rows. See [here][1] for an overview of locking in SQL server.
[1]: ... |
There are way too many kinds of web projects in Visual Studio 2008. There are Web Site Projects vs. Web Application Projects and they limit you in different ways. It's a good example of Microsoft providing too many choices instead of focusing on one strong solution. Even within the Web site Project option, there are... |
Will this approach using [Console.KeyAvailable][1] help?
class Sample
{
public static void Main()
{
ConsoleKeyInfo cki = new ConsoleKeyInfo();
do {
Console.WriteLine("\nPress a key to display; press the 'x' key to quit.");
// Your code coul... |
continue feels wrong to me. break gets you out of there, but continue seems just to be spaghetti.
On the other hand, you can emulate continue with break (at least in Java).
for (String str : strs) contLp: {
...
continue contLp;
...
}
continue can be useful in some circums... |
@alanw123: p4pr is close to what I'm looking for, but it doesn't cross branch boundaries:
last if $type eq 'branch';
That was the main problem I had when I tried writing my own utility -- you can't (easily) tell how the lines map back to the file that was branched from. |
In Applescript, how can I find out if a menu item is selected/focused? |
|menu|applescript|focus|macos| |
|macos|menu|applescript|focus| |
|macos|menu|focus|applescript| |
I have an script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, type Esc instead of clicking the Help men... |
I have an script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, type Esc instead of clicking the Help men... |
Even better than using decimals is using just plain old integers (or maybe some kind of bigint). This way you always have the highest accuracy possible, but the precision can be specified. For example the number `100` could mean `1.00`, which is formatted like this:
int cents = num % 100;
int dollars = (num... |
Even better than using decimals is using just plain old integers (or maybe some kind of bigint). This way you always have the highest accuracy possible, but the precision can be specified. For example the number `100` could mean `1.00`, which is formatted like this:
int cents = num % 100;
int dollars = (num... |
Treat the following as pseudo-code..
try:
from hashlib import sha as hasher
except ImportError:
# You could probably exclude the try/except bit,
# but older Python distros dont have hashlib.
try:
import sha as hasher
except ImportError:
... |
missing WMI namespace on Vista/Server 2008 |
|internet-explorer|namespaces|wmi| |
What is equivalent to the root\CIMV2\Applications\MicrosoftIE namespace on Vista/Server 2008?
The root\cimv2\Applications\MicrosoftIE namespace dates back to at least Internet Explorer 5.00.2920.0000, which happens to be the version of Internet Explorer that shipped with Windows 2000, but it looks like it is removed... |
Ok right, I understand more where you are coming from..
How about:
- Create a static method that returns the date constant. This overcomes the international issue since it is returned as the specific DateTime value.
- Now I remember optional params from my VB6 days, but can you not just overload the method? ... |
Ok right, I understand more where you are coming from..
How about:
- Create a static method that returns the date constant. This overcomes the international issue since it is returned as the specific DateTime value.
- Now I remember optional params from my VB6 days, but can you not just overload the method? ... |
Something like this
--Grab the next message id
begin tran
declare @MessageId uniqueidentifier
select top 1 @MessageId = ActionMessageId from UnacknowledgedDemands with(holdlock, updlock);
--Acknowledge the message
update ActionMessages
set AcknowledgedTime = getdate()
w... |
How do I expose data in a JSON format through a web service using Rails? |
|ruby-on-rails|web-services|json| |
Is there an easy way to return data to web service clients in JSON using Rails? |
Fetchmail seems like the way to go. I can use PHP to generate/edit a fetchmail command file, so that will cover the public sign-up. I'm looking for a package/script who allready does this.
The Gmail pull only works with POP3, not with IMAP. |
goto can be used as a continue, but not the reverse.
You can "goto" anywhere, thus break flow control arbitrarily.
Thus continue, not nearly as harmful. |
Read more about SQL Server Select Locking [here][1] and [here][2]. SQL Server has the ability to invoke a table lock on a select. Nothing will happen to the table during the transaction. When the transaction completes, any inserts or updates will then resolve themselves.
[1]: http://www.quest-pipelines.com/newsl... |
I do believe that part of your issue is that you are trying to us a singular function for two separate uses... passwords and transaction_id
these really are two different problem areas and it really is not best to try to address them together. |
as long as you know the x and y position that falls on the particular monitor you can do:
var x = 0;
var y = 0;
var myWin = window.open(''+self.location,'mywin','left='+x+',top='+y+',width=500,height=500,toolbar=1,resizable=0');
|
If continue is causing a problem with readability, then chances are you have other problems. For example, massive amounts of code inside a for loop. If you have to write large for loops, I would try to stick to using continue close to the top of the for loop. Otherwise, a continue buried deep in the middle of a for ... |
I have a script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, type Esc instead of clicking the Help menu... |
Set the AutoPostBack property of DropDownList to true. |
I don't think it's so bad. Only problem is that because of large metadata and amount of memory your application takes it's more possible that some parts of application which are in use will be located at different memory pages which can 'cause some performance leaks, but it's very low segment of application where this ... |
Really bad is a difficult term to quantify, I guess depends on the scale of things, in general I'd say that if you can avoid loading stuff you don't need then you should. But of course if you are using reflection to determine if you *can* use it, you first have to load it...chicken and the egg problem.
Something to ... |
A good choice: [HTTP Digest authentication](http://advosys.ca/viewpoints/2006/08/http-digest-authentication/)
Harder to pull off well, but an option: [Client-side hashing with Javascript](http://blog.paranoidferret.com/index.php/2007/07/22/secure-authentication-without-ssl-using-javascript/)
|
I know many people have argued that the data should be natural, but you should be using a primary key that is completely separate from your data if you're going to be supporting soft deletes without the intention of always re-using the previous record when this situation arises.
Having a divorced primary key will al... |
Are you stating that padding and/or margin values shouldn't co-exist with a DOM element that also has a width value assigned to it? If so, that is only true if you do not want to write CSS that is compatible with both IE as well as browsers which implement web standards (e.g. Firefox). It would be difficult to achiev... |
Django -vs- Grails -vs- ??? |
|python|django|frameworks| |
I'm wondering if there's such a thing as Django-like ease of web app development combined with good deployment, debugging and other tools?
Django is a very productive framework for building content-heavy sites; the best I've tried and a breath of fresh air compared to some of the Java monstrosities out there. Howev... |
As highlighted in other posts:
1) Calls to new/delete allocate memory and may call constructors/destructors (C++ '03 5.3.4/5.3.5)
2) Mixing Array/Non Array versions of new and delete is undefined behaviour. (C++ '03 5.3.5/4)
Looking at the source it appears that someone did a search and replace for 'malloc' ... |
As highlighted in other posts:
1) Calls to new/delete allocate memory and may call constructors/destructors (C++ '03 5.3.4/5.3.5)
2) Mixing Array/Non Array versions of new and delete is undefined behaviour. (C++ '03 5.3.5/4)
Looking at the source it appears that someone did a search and replace for 'malloc' ... |
Go for the SCSI and LSILogic. IDE and BusLogic are for compatibility reasons. Like when you do physical2virtual...
There's a whitepaper from vmware showing the difference between LSILogic and BusLogic, which in my opinion is rather small:
[http://www.vmware.com/pdf/ESX2_Storage_Performance.pdf][1]
[1]: http:... |
It's perfectly fine to build your application using Ext JS/DWR/Spring/Hibernate. |
More a comment on your original question than an actual answer but Delphi has had much easier to remember (and type) keyboard shortcuts than what you quote available for quite some time now:
Set bookmark 1: Ctrl-Shift-1
Go to bookmark 1: Ctrl-1
If you ever go back to Delphi, this should make your life so much ... |
It looks pretty standard to me. The only personal change I'd make is aligning the curly-braces with the start of the previous line, rather than the start of the next line, but that's just a personal choice.
Anyway, the style of formatting you're looking at there is a standard one for C and C++, and is used because i... |
Is there a distributed VCS that can manage large files? |
|dvcs|vcs| |
Is there a distributed version control system (git, bazaar, mercurial, darcs etc.) that can handle files larger than available RAM?
I need to be able to commit large binary files (i.e. datasets, source video/images, archives), so I don't need to be able to diff them, just be able to commit and then update when the f... |
Is there a distributed version control system (git, bazaar, mercurial, darcs etc.) that can handle files larger than available RAM?
I need to be able to commit large binary files (i.e. datasets, source video/images, archives), but I don't need to be able to diff them, just be able to commit and then update when the ... |
Getting a remoting exception does not guarantee that your server is up and running. If something else happens to be running and listening on that port, the connection will succeed, and you will not get a socket exception. What happens in this case depends on how the application which actually got your connection beha... |
You usually use a third party library for these things. For example, you would link in a database library for say Oracle that would allow you to talk to the database. Because the underlying file type, ( i.e. Excel spreadsheet vs Openoffice, Oracle vs MySQL, etc. ) differ these libraries abstract away your need to care... |
There are a number of standards of course. The likely one to use is some flavor of xml since there are libraries and tools that already exist to help you work with it, but nothing is stopping you from inventing your own. |
Module::Build is better by any means, but it is less widely supported than ExtUtils::MakeMaker (more specifically, older versions of Perl don't support it out of the box). It depends on your needs. |
You basically have to come up with your own file format and write binary data.
You can also serialize your object model and write the output to a file, but that's usually less efficient.
Better to use an existing database, or use xml (or other) for simple needs. If you want to write a file in a format that already ... |
An explicit cursor is defined as such in a declaration block:
DECLARE
CURSOR cur IS
SELECT columns FROM table WHERE condition;
BEGIN
...
an implicit cursor is implented directly in a code block:
...
BEGIN
SELECT columns INTO variables FROM table where condition;
... |
To clarify what Gillian said about 4 string, if you have something like this:
string a,b,c,d;
a = b + c + d;
then it would be faster using strings and the plus operator. This is because (like Java, as Eric points out), it internally uses StringBuilder automatically (Actually, it uses a primitive that St... |
According to [MSDN][1], if you set the column width to -1 then it will autosize to the widest item
[1]: http://msdn.microsoft.com/en-us/library/system.windows.forms.columnheader.width(VS.71).aspx |
.NET Date Const (with Globalization) |
|datetime| |
Does anyone know of a way to declare a date constant that is compatible with international dates?
Ive tried:
public const ADate as Date = #12/31/04# - not international compatible
public shared readonly ADate As New Date(12, 31, 04) - breaking change if you have an optional parameter that defaults to this value ... |
|vb.net|datetime| |
You can't specify the monitor, but you can specify the position of the popup window as being relative to the where the click caused the window to popup.
Use the getMouseXY() function to get values to pass as the left and top args to the window.open() method. (the left and top args only work with V3 and up browsers)... |
Some Tomcat webapps not opening |
|web-applications|tomcat|spring|run| |
I downloaded a couple of webapps and placed them in my <tomcat dir>/webapps folder.
Some of them I could open by going to http://localhost:8080/app1 and it would open.
However, some others I would do the exact same thing and go to http://localhost:8080/app2 and it will display "HTTP Status 404 - /app2/", even though ... |
|java|tomcat|spring|web-applications|run| |
One way or another you do need a second thread. You could use asynchronous IO to avoid declaring your own:
- declare a ManualResetEvent, call it "evt"
- call System.Console.OpenStandardInput to get the input stream. Specify a callback method that will store its data and set evt.
- call that stream's Begi... |
I assume you have the source to 1.exe (if you're debugging it), then just insert a statement near the beginning that will cause it to hang around long enough to attach a debugger. ( getch() if you're desperate and it's not interactive. )
After the attach, just skip to the next statement and let it go. |
It's not a method, it's a field. The field is called __name__. class.__name__ will give the name of the class as a string. object.__class__.__name__ will give the name of the class of an object. |
It's not a method, it's a field. The field is called `__name__`. `class.__name__` will give the name of the class as a string. `object.__class__.__name__` will give the name of the class of an object. |
The most idiomatic way to do this is to use symbols. For example, instead of:
enum {
FOO,
BAR,
BAZ
}
myFunc(FOO);
...you can just use symbols:
# You don't actually need to declare these, of course--this is
# just to show you what symbols look like.
:foo
... |
You could put in some preprocessor commands for debug builds - just remember to build your release in release mode:
#ifdef DEBUG
Thread.Sleep(10000);
#endif |
I would say the D programming language is a good option. You can link to C object files and interface with C++ code through C libraries. D has garbage collection, inline assembly, and game developers have created bindings to SDL and OpenGL libraries, and are also actively working on new game development apis. I love D.... |
ASP.NET Custom Controls - Alternatives to PostBack? |