instruction stringlengths 0 30k ⌀ |
|---|
You may want to consider looking at [J/Invoke][1] or [JNA (Java Native Access)][2] as an alternative to the much berated JNI.
[1]: http://www.jinvoke.com/
[2]: https://jna.dev.java.net/ |
If file length is something you retrieve often, why not implement a property in the BDictionary (?) class... so that you code becomes:
BDictionary torrent = BItem.DecodeFile("my.torrent");
int filelength = torrent.FileLength;
That way the implementation details are hidden from the user. |
I think I would make the this[int] and this[string] accessors virtual and override them in BList/BDictionary. Classes where the accessors does not make sense should cast a NotSupportedException() (perhaps by having a default implementation in BItem).
That makes your code work in the same way and gives you a more rea... |
Try "Clean Solution", then building SuggestionProcessor, and after that clean and rebuild the web solution. |
Here's what I did based on
a) Epso's comments and
b) the fact that I only had Windows Task Manager to play with....
I logged onto the host machine, opened Task Manager and used the view menu to add the PID column to the Processes tab.
I wrote down (yes, with paper and a pen) the PID's for each and every... |
|windows|winapi| |
Is the documentation for Rich Edit Controls really as bad (wrong?) as it seems to be? Right now I'm manually calling LoadLibrary("riched20.dll") in order to get a Rich Edit Control to show up. The documentation for Rich Edit poorly demonstrates this in the first code sample for using Rich Edit controls.
It talks a... |
According to Jarl it works, check [codeproject][1] for a question and answer with sample code:
[1]: http://www.codeproject.com/KB/threads/Rcf_Ipc_For_Cpp.aspx?fid=248794&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=101&select=2365783 |
Apart from the security and usability email delivery can be another problem. Depending on the user's email provider, email delivery can be delayed from a few minutes to few hours. |
Attempting to second-guess the garbage collector is generally a very bad idea. On Windows, the garbage collector is [a generational one][1] and can be relied upon to be pretty efficient. There are some noted exceptions to this general rule - the most common being the occurrence of a one-time event that you know for a f... |
x86 Remote Debugger Service on x64 |
|visual-studio|debugging|remote-debugging| |
Is it possible to install the x86 Remote Debugger as a Service on a 64bit machine? I need to attach a debugger to a Session 0 process. The process runs 32bit but the debugger service that gets installed is 64bit and wont attach to the 32bit process. I need to attach to managed code. |
|linux|bash|shell| |
Hmm.. one solution could be to store a table of dates with an offset based on a count of non-off days from the beginning of the year. Lets say jan. 2 is an off day. 1/1/08 would have an offset of 1 (or 0 if you like to start from 0). 1/3/08 would have an offset of 2, because the count skips 1/2/08. From there its a si... |
yes, of course. You can change the licence to whatever you want.
Go to your admin page, then edit registration from the menu, view Public Info, then edit the Trove categorisation. You need to remove then add a new category. Easy (if a little link-happy).
This applies if you're an admin of the project, no matter h... |
Casting array of objects (which implement interface IFoo) to IFoo[] in C# |
|c#| |
class A : IFoo
{
}
...
A[] arrayOfA = new A[10];
if(arrayOfA is IFoo[])
{
// this is not called
}
Q1: Why is arrayOfA not an array of IFoos?
Q2: Why can't I cast arrayOfA to IFoo[]
|
You can generate a table of working days in advance.
WDId | WDDate
-----+-----------
4200 | 2008-01-08
4201 | 2008-01-09
4202 | 2008-01-12
4203 | 2008-01-13
4204 | 2008-01-16
4205 | 2008-01-17
Then do a query such as
SELECT DeliveryDay.WDDate FROM WorkingDay OrderDay... |
I did this with one project by doing the following:
1. Create a C# class library
2. Reference the C# class library from the VB web application
3. Create the code behind class in the C# library
4. Update the "Inherits" property in the aspx/ascx file to reference the C# class (this file still exists in the orig... |
How do I use TextMate as my command line subversion message editor? |
|command-line|svn|textmate| |
Simply setting the SVN_EDITOR variable to "mate" does not get the job done. It opens TextMate when appropriate, but then when I save the message and exit, I'm prompted to continue, abort or try again. It seems like the buffer isn't returned to the svn command for use. |
What is the best process for a new ASP.NET web app from the ground up? |
|c#|asp.net|web-applications|unit-testing| |
|sql|sql-server|t-sql| |
I'm trying to write a stored procedure to select employees who have birthdays that are upcoming.
`SELECT * FROM Employees WHERE Birthday > @Today AND Birthday < @Today + @NumDays`
This will not work because the birth year is part of Birthday, so if my birthday was '09-18-1983' that will not fall between '09-18-... |
You need to install the Visual Studios 2008 runtime on the target computer:
> http://www.microsoft.com/downloads/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en
Alternatively, you could also link the run time statically, in the project properties window go to:
> c++ -> Code Generation... |
You can also use the deprecated $` variable, if you're willing to have all the REs in your program execute slower. From perlvar:
$‘ The string preceding whatever was matched by the last successful pattern match (not
counting any matches hidden within a BLOCK or eval enclosed by the curre... |
> Do you generally assume that toString() on any given object has a low cost? I do.
Why would you do that? *Profile* your code if you're running into performance issues; it'll save you a lot of time working past incorrect assumptions. |
Flash can give you a list of fonts on the user's machine among other things. Javascript can send information when the mouse stops over an ad without clicking it. You can also get the window size, whether the site is open in a frame, if popups or specific plugins have been blocked, looking for Javascript features can te... |
Modifications to your original:
1. can be escaped ( i think its an option in some browsers )
2. only avoidable with a proxy ( javascript can contravene this however with smart lookaround )
3. is unreliable, easily forged.
4. And assuming it was not wiped by browser closure ( session cookie ) and cookie... |
Is it possible to install the x86 Remote Debugger as a Service on a 64bit machine? I need to attach a debugger to managed code in a Session 0 process. The process runs 32bit but the debugger service that gets installed is 64bit and wont attach to the 32bit process.
Here is the error when I try to use the remote ... |
Is it possible to install the x86 Remote Debugger as a Service on a 64bit machine? I need to attach a debugger to managed code in a Session 0 process. The process runs 32bit but the debugger service that gets installed is 64bit and wont attach to the 32bit process.
I tried creating the Service using the SC comma... |
If you want a pure Python solution, you can take a look at [Scapy][1] to craft packets (you need to send ARP request, and inspect replies). Or if you don't mind invoking external program, you can use `arping` (on Un*x systems, I don't know of a Windows equivalent).
[1]: http://www.secdev.org/projects/scapy/
|
I agree that just learning the patterns is not enough. The problem with most books is that they do not provide real-world examples. I've heard that Head First Design Patterns, as some suggested earlier, is a good one.
Another thing is that most books are intentionally **not language-specific**, which may be both a g... |
It seems that there is not a native way of doing this with Python. Your best bet would be to parse the output of "ipconfig /all" on Windows, or "ifconfig" on Linux. Consider using os.popen() with some regexps.
|
Tell if a Javascript function is defined - is this a good way? |
|javascript| |
This is a follow up question to [this](http://stackoverflow.com/questions/85815/how-to-tell-if-a-javascript-function-is-defined) question.
I like (and understand) the solution there. However, in the code I am working in, another way to solve the same problem is used:
function exist(sFN) {
if(self[sFN])... |
This is a follow up question to [This Question](http://stackoverflow.com/questions/85815/how-to-tell-if-a-javascript-function-is-defined).
I like (and understand) the solution there. However, in the code I am working in, another way to solve the same problem is used:
function exist(sFN) {
if(self[sFN])... |
Any problems running SharpDevelop 3.0 and Visual Studio 2008 side by side? |
|c#|visual-studio|sharpdevelop| |
I have been asked to lend a hand on a hobby project that a couple friends are working on, they are using SharpDevelop 3.0 (Beta 2 I think, but it might be Beta 1) is there any hassle for me to install and use this IDE given that I have Visual Studio 2008 installed? |
Performance degradation will happen when you use large ACLs for each list item. Just make sure that item-level permissions basically have the minimum entries. For example:
- The user that has permissions to edit that item
- A security group that contains all the users with only Reader permissions.
So, can Sh... |
Performance degradation will happen when you use large ACLs for each list item. Just make sure that item-level permissions basically have the minimum entries. For example:
- The user that has permissions to edit that item
- A single security group that contains all the users with only Reader permissions.
So,... |
You can't really wrap this in a method, but it's so simple there is really no need.
function bob()
{}
if( typeof bob == "function" )
alert( "bob exists" );
if( typeof dave != "function" )
alert( "dave doesn't" );
|
Renaming/Mapping Cygwin Folders |
SQL query to calculate coordinate proximity |
|sql|geocoding| |
I'm using this formula to calculate the distance between entries in my (My)SQL database which have latitude and longitude fields in decimal format:
6371 * ACOS(SIN(RADIANS( %lat1% )) * SIN(RADIANS( %lat2% )) + COS(RADIANS( %lat1% )) * COS(RADIANS( %lat2% )) * COS(RADIANS( %lon2% ) - RADIANS( %lon1% )))
Substi... |
I'm using this formula to calculate the distance between entries in my (My)SQL database which have latitude and longitude fields in decimal format:
6371 * ACOS(SIN(RADIANS( %lat1% )) * SIN(RADIANS( %lat2% )) + COS(RADIANS( %lat1% )) * COS(RADIANS( %lat2% )) * COS(RADIANS( %lon2% ) - RADIANS( %lon1% )))
Substi... |
In visual studio 2005/8 you can right click on a class and then select View in Class Diagram which will create a new ClassDiagram containing the selected class and any related classes. |
From [SetFileTime's documentation][1]:
"NTFS delays updates to the last access time for a file by up to one hour after the last access."
There's no real point turning this off - the original article is wrong, the data is not written out on every access.
[1]:http://msdn.microsoft.com/en-us/library/ms724933(VS.8... |
From [SetFileTime's documentation][1]:
"NTFS delays updates to the last access time for a file by up to one hour after the last access."
There's no real point turning this off - the original article is wrong, the data is not written out on every access.
EDIT:
As to why the author of that article claimed a 1... |
I doubt that subclipse and then svn can use your eclipse proxy settings. You'll probably need to set the proxy for your svn program itself. Trying to check out the files using svn from the command line should tell you if that works.
If svn can't connect either then put the proxy settings in your servers file in yo... |
Here's what I did based on
a) @Espo 's comments and
b) the fact that I only had Windows Task Manager to play with....
I logged onto the host machine, opened Task Manager and used the view menu to add the PID column to the Processes tab.
I wrote down (yes, with paper and a pen) the PID's for each and eve... |
I suppose the adding people toward the end of the work could speed things up if:
1. The work can be done in parallel.
2. The amount saved by added resources is more than the amount of time lost by having the people experienced with the project explain things to those that are inexperienced.
|
I suppose the adding people toward the end of the work could speed things up if:
1. The work can be done in parallel.
2. The amount saved by added resources is more than the amount of time lost by having the people experienced with the project explain things to those that are inexperienced.
EDIT: I forgot to m... |
If you have FTP/SFTP access you could just go ahead and upload phpMyAdmin yourself.
I'm using this little package to make automated mysql backups from a server I only have FTP access to:
<http://www.taw24.de/download/pafiledb.php?PHPSESSID=b48001ea004aacd86f5643a72feb2829&action=viewfile&fid=43&id=1>
The site ... |
[tcpdump][1] if you need command line or something more visual like [wireshark][2]
If you want to write something on your own use [libpcap][3].
[1]: http://www.tcpdump.org/
[2]: http://www.wireshark.org/
[3]: http://www.tcpdump.org/ |
There are two accepted methods for retrieving these kind of things by OpenID: SReg and Attribute Exchange (AX). Both of these are extensions to the standard OpenID specification; SReg is the older of the two and specifies a set of fields that can be requested and sent with authentication, whereas AX allows requesting o... |
Tables used as pure layout does pose some problems for accessability (that I've heard). But I understand what is being asked here that somehow you're crippling the web by using a table to ensure correct alignment of something on your page.
I've heard people argue before that FORM labels and inputs are, in fact, data... |
MSDN comparison -- [Comparing Web Site Projects and Web Application Projects][1]
Webcast on ASP.NET -- [Web Application Projects vs. Web Site Projects in Visual Studio 2008][2]
*"In this webcast, by request, we examine the differences between web application projects and web site projects in Microsoft Visual Stud... |
Well, it converts your web site to a web application project. As for the advantages, here is some further reading:
MSDN comparison -- [Comparing Web Site Projects and Web Application Projects][1]
Webcast on ASP.NET -- [Web Application Projects vs. Web Site Projects in Visual Studio 2008][2]
*"In this webcast, ... |
This looks to be a similar issue for .net 2.0, vista and oracle http://forums.oracle.com/forums/thread.jspa?threadID=516250 |
You would want to parse the output of 'arp', but the kernel ARP cache will only contain those IP address(es) if those hosts have communicated with the host where the Python script is running.
ifconfig can be used to display the MAC addresses of local interfaces, but not those on the LAN. |
To be non-intrusive, you can also put `serialize` in the namespace of the class being serialised, or of the archive class, thanks to [Koenig lookup](http://en.wikipedia.org/wiki/Koenig_lookup). See [Namespaces for Free Function Overrides](http://www.boost.org/doc/libs/1_36_0/libs/serialization/doc/serialization.html#na... |
Not an expert here, but "littering" your xaml with x:Uids is not worse than "littering" your Windows Forms code with all the string table nonsense you have to do for localizing them.
As far as I understand, WPF apps still support "all the Framework CLR resources including string tables, images, and so forth." which ... |
You shouldn't.
You could attach some script to the onbeforeunload event of a page and confirm with the user that's what they want to do; and you can go a bit further and *try* to [disable it][1] but of course that will only work for users who have javascript turned on. Instead look at rewriting the app so you don't ... |
You could post the data on each form to a _NEW window. This will disable the back button on each window, but without javascript it might be difficult to force the old one closed. |
Go with N2 if you want to get up and running in no time with a couple of nice features packed. Also, it is really targetted against extensibility and clean code.
http://www.n2cms.com |
Here's a previous post on it:
http://stackoverflow.com/questions/54539/prevent-use-of-the-back-button-in-ie
|
[Recording macros][1]
[1]: http://julipedia.blogspot.com/2005/12/vim-macros.html
|
I try to ensure that the number of places using of try/finally greatly outnumbers the number of places using try/catch. catch will usually be reserved for catching exceptions at the top-level - where they can sensibly be handled, or dealing with exceptions from platform APIs.
In this case, as long as you give excep... |
findstr is OK and has the advantages of being on all machines already, |
I find the best way is using a class that allows you to bind your code so you never have to worry about manually escaping your data. |
I have spent a while thinking about this and came to some conclusions. Rails session cookies are tamper-proof by default, so you really don't have to worry about a cookie being modified on the client end.
Here is what I've done:
- Session cookie is set to be long-lived (6 months or so)
- Inside the session ... |
Your current strategy is the correct one. You're tracking so many kinds of data, so you'll need lots of tables. That's just how it is. Is the DBMS complaining? |
@huck Even with windows authentication you can still use SqlCommand and SqlConnection to execute, and you don't have to re-invent the wheel for exception handling.
A simple connection configuration and a single SqlCommand can execute it without issue. |
If you want one Windows service to start two WCF services, you'll need one ServiceInstaller that has two ServiceHost instances, both of which are started in the (single) OnStart method.
You might want to follow the pattern for ServiceInstaller that's in the template code when you choose to create a new Windows Servi... |
You'll be constantly using the ReDim keyword, which is _extremely_ inefficient.
Are you using .Net? If so, consider using a System.Collections.Generic.List(Of Byte) instead. You can use it's .AddRange() method to append your bytes, and it's .ToArray() method to get an array back out if you really need one. |
Your question doesn't seem to be very clear. You should probably not have the array of bytes as public. It should probably be private and you should provide a set of public functions that allow users of the class to perform operations against the array. |
The problem you're facing is solved by so-called Business Intelligence software. This software tends to be bloated and expensive, but if you know your way around them you will be able to crank out such reports in no time at all.
I'm only familiar with one particular proprietary solution, which isn't too great eit... |
The upgrade adviser can also help.
Look at the execution plans with production data in the database.
Though my best advice is to test, test, test.
When people started moving from 2000 to 2005 it wasn't the breaking features that were show stoppers it was the change in how queries performed with the new optim... |
If I understand the question, then yes. You just need a `;` after the `27544`:
<?xml version="1.0" encoding="Windows-1252"?>
<xml>
<value>殘</value>
</xml>
Or are you wondering how to generate this XML programmatically? If so, what language/environment are you working in? |
<p>Did you concider parsing a simple "path" so you could write it this way:</p>
<p><code>
BDictionary torrent = BItem.DecodeFile("my.torrent");<br />
int filelength = (int)torrent.Fetch("info.files.0.length");
</code></p><p>
Perhaps not the best way, but the readability increases(a little)</p> |
How to check if an object is serializable in C# |
|c#|serialization| |
I am looking for an easy way to check if an object in C# is serializable.
As we know you make an object serializable by either implementing the *ISerializable* interface or by placing the *[Serializable]* at the top of the class.
What I am looking for is a quick way to check this without having to reflect the cla... |
I am looking for an easy way to check if an object in C# is serializable.
As we know you make an object serializable by either implementing the *ISerializable* interface or by placing the *[Serializable]* at the top of the class.
What I am looking for is a quick way to check this without having to reflect the cla... |
I am looking for an easy way to check if an object in C# is serializable.
As we know you make an object serializable by either implementing the *ISerializable* interface or by placing the *[Serializable]* at the top of the class.
What I am looking for is a quick way to check this without having to reflect the cla... |
!!DISCLAIMER!! I work on a commercial static analysis tool (not PC Lint). !!DISCLAIMER!!
There are several issues with a simple non parsing approach:
1) Overload Sets:
It's possible that an overloaded function has declarations that come from different files. It might be that removing one header file results i... |
The difference is very platform-specific.
clock() is very different on Windows than on Linux, for example.
For the sort of examples you describe, you probably want the "timeit" module instead.
|
If stored procedure generation is all you are after, CodeSmith is a decent option at a fraction of the cost of IronSpeed. There are several sproc templates available, and you can create your own or tweak an existing if that is what you need. You can also gen .Net code to your hearts content with CodeSmith. Tons of bu... |
Over a decade ago, when I was learning the ways of the Computer, the Old Wise Men With Beards explained how C and C++ are the tools of the industry. No one used Pascal and only the foolhardy would risk their companies with assembler.
And of course, **no one would even mention the awful slow ugly thing called Java**.... |
**Edit:** I wrote this before reading the update to the original question. See my other answer for a better answer to the updated question. I will leave this as is as a warning against being the fastest gun in the west =)
Over a decade ago, when I was learning the ways of the Computer, the Old Wise Men With Beards e... |
How to set the header sort glyph in a .NET ListView? |
|listview|header|sorting|glyph| |