instruction stringlengths 0 30k ⌀ |
|---|
The C# newbie has another simple question!
Does C# have built-in support for parsing strings of page numbers? By page numbers, I mean the format you might enter into a print dialog that's a mixture of comma and dash-delimited.
Something like this:
1,3,5-10,12
What would be really nice is a solution tha... |
The C# newbie has another simple question!
Does C# have built-in support for parsing strings of page numbers? By page numbers, I mean the format you might enter into a print dialog that's a mixture of comma and dash-delimited.
Something like this:
1,3,5-10,12
What would be really nice is a solution tha... |
Migrating from ASP Classic to .NET and pain mitigation |
|asp.net|asp|migration| |
|asp.net|migration|asp-classic| |
|asp.net|asp-classic|migration| |
We're in the process of redesigning the customer facing section of our site in .NET 3.5. It's been going well so far, we're using the same workflow and stored procedures for the most part, the biggest changes are the UI, the ORM (from dictionaries to LINQ), and obviously the language. Most of the pages to this point ha... |
We're in the process of redesigning the customer facing section of our site in .NET 3.5. It's been going well so far, we're using the same workflow and stored procedures for the most part, the biggest changes are the UI, the ORM (from dictionaries to LINQ), and obviously the language. Most of the pages to this point ha... |
Regarding Java 1.5 and autoboxing there is an important "quirk" that comes to play when comparing Integer objects.
In Java, Integer objects with the values -128 to 127 are immutable (that is, for one particular integer value, say 23, all Integer objects instantiated through your program with the value 23 points to t... |
Regarding Java 1.5 and [autoboxing](http://en.wikipedia.org/wiki/Autoboxing#Autoboxing) there is an important "quirk" that comes to play when comparing Integer objects.
In Java, Integer objects with the values -128 to 127 are immutable (that is, for one particular integer value, say 23, all Integer objects instantia... |
Paging SQL Server 2005 Results |
|sql|paging| |
How do I page results in SQL Server 2005?
I SQL Server 2000, there was no reliable way todo this but I'm now wondering if SQL Server 2005 has any built in method.
What I mean by paging is, for example, if I list users by their username, I want to be able to only return the first 10 records, then the next 10 recor... |
I got it with:
select
1 as tag,
null as parent,
AccountNumber as 'root!1!clientID!element'
from
Location.LocationMDAccount
where
locationid = 'long-guid-here'
for xml explicit
Thanks!
Edit: I think I like KG's way better, but Chris Leon answered what I really was try... |
I got it with:
select
1 as tag,
null as parent,
AccountNumber as 'root!1!clientID!element'
from
Location.LocationMDAccount
where
locationid = 'long-guid-here'
for xml explicit
Thanks! |
> Will access to these tables through
> the GUID key be slow?
There are other problems with GUIDs, you see GUIDs are not sequential, so inserts will be scattered all over the place, this causes page splits and index fragmentation
In SQL Server 2005 MS introduced NEWSEQUENTIALID() to fix this, the only problem fo... |
I agree on the 7 item limit Boojiboy mentions. Beyond that, it may be worth looking at anonymous (or specialized) types, IDictionary, or indirection via primary key to another data source.
|
I think the "pure OOP" answer is that if operations on the class are invalid when certain members aren't initialized, then these members must be set by the constructor. There's always the case where default values can be used, but I'll assume we're not considering that case. This is a good approach when the API is fi... |
I think your question is more about the design of your classes than about the number of arguments in the constructor. If I needed 20 pieces of data (arguments) to successfully initialize an object, I would probably consider breaking up the class. |
what partition type are you using? having millions of small files in one directory it might be a good idea to use JFS or ReiserFS which have better performance with many small sized files. |
Mutexes are useful in situations where you need to enforce exclusive access to a resource accross multiple processes, where a regular lock won't help since it only works accross threads. |
I'm not sure you need to get the pdb file into the GAC. (At least, the fix I'm about to describe works just fine for debugging SharePoint web parts in VS2005, which have a similar problem.)
There's a checkbox marked "Enable Just My Code (Managed Only)" in Tools-->Options-->Debugging; if you uncheck it, then Visual S... |
Should be simple:
foreach( string s in "1,3,5-10,12".Split(',') )
{
//try and get the number
int num;
if( int.TryParse( s, out num ) )
yield return num;
//otherwise we might have a range
else
{
//split on the range delimiter... |
|c|linux|64-bit| |
Some code that rounds up the division to demonstrate (C-syntax):
#define SINT64 long long int
#define SINT32 long int
SINT64 divRound(SINT64 dividend, SINT64 divisor)
{
SINT32 quotient1 = dividend / divisor;
SINT32 modResult = dividend % divisor;
SINT32 multResul... |
Spread vs MPI vs zeromq? |
|networking|api|distributed|cluster-analysis|messaging| |
In one of the answers to [Broadcast like UDP with the Reliability of TCP][1], a user mentions the [Spread][2] messaging API. I've also run across one called [ØMQ][3]. I also have some familiarity with [MPI][4].
So, my main question is: why would I choose one over the other? More specifically, why would I choose... |
Is there anyway to run ruby on rails applications on a windows box? |
|windows|ruby|ruby-on-rails| |
I'm looking to run Redmine, a Ruby on Rails app, on a vps windows box. The only thing I can really think of is running a virtual linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine?
Also, this will be an internal ... |
You can install SQLite and a Rails server like Mongrel on a Windows machine. I used Aptana to run a development environment, but I'm sure that there are better alternatives that don't require the IDE to be open to run. But this proves it is possible. |
My 2c:
I'd recommend basing your system on Debian - the aptitude system has become the de facto way to quickly install and update programs on Linux. As for windowing managers, in my opinion Xfce hits the right balance between being lightweight and functional. Also, for security only install essential network service... |
My 2c:
I'd recommend basing your system on [Debian][1] - the [apt][2] system has become the de-facto way to quickly install and update programs on Linux. [Ubuntu][3] is Debian based with an emphasis on usability and compatibility. As for windowing managers, in my opinion [Xfce][4] hits the right balance between bein... |
My 2c:
I'd recommend basing your system on [Debian][1] - the [apt][2] system has become the de-facto way to quickly install and update programs on Linux. [Ubuntu][3] is Debian based with an emphasis on usability and compatibility. As for windowing managers, in my opinion [Xfce][4] hits the right balance between bein... |
Using const is a reasonable choice.
You may also wish to check out the boost C++ library for their shared pointer implementation. It provides the advantages of pointers i.e. you may have the requirement to return a shared pointer to "null" which a reference would not allow.
http://www.boost.org/doc/libs/1_36_0/libs... |
> In Subversion (and CVS), the repository is first and foremost. In git
> and mercurial there is not really the concept of a repository in the
> same way; here changes are the central theme.
+1
The hassle in CVS/SVN comes from the fact that these systems do **not**
remember the parenthood of changes. In Git a... |
Should be simple:
foreach( string s in "1,3,5-10,12".Split(',') )
{
//try and get the number
int num;
if( int.TryParse( s, out num ) )
yield return num;
//otherwise we might have a range
else
{
//split on the range delimiter... |
Blackberry publishes its SDK on its web site. Its apps run J2ME, so with some Java experience it shouldn't be too difficult to get started. They also give you an emulator. Disclaimer: I have no experience in writing Blackberry apps, but I looked into it once.
I would not recommend a PalmOS based handset. I have ... |
If you aren't content with DataRow or SqlDataReader, you should look at an ORM system like Linq to Sql or nHibernate, instead of re-inventing the wheel yourself.
(By the way, this is called the "ActiveRecord" pattern) |
Create object from database row |
|.net| |
Let's say I'm building a data access layer for an application. Part of that is that I have a class definition for a particular object that is stored in the database. Of course, the data access itself returns the results in the form of a datareader, typed or untyped dataset, or similar, usually with the data needed to... |
Let's say I'm building a data access layer for an application. Typically I have a class definition for a each kind of object that is stored in the database. Of course, the actual data access retrieves data in the form of a datareader, typed or untyped dataset, or similar, usually with the data needed to create one ob... |
Force unmount of NFS-mounted directory |
SQL Server 2000 does not keep track of this information for you.
There may be creative / fuzzy ways to guess what this date was depending on your database model. But, if you are talking about 1 table with no relation to other data, then you are out of luck. |
How do you printf an unsigned long long int? |
|c|syntax| |
#include <stdio.h>
int main() {
unsigned long long int num = 285212672; //FYI: fits in 29 bits
int normalInt = 5;
printf("My number is %d bytes wide and its value is %ul. A normal number is %d.\n", sizeof(num), num, normalInt);
return 0;
}
Output:
My number is 8 bytes w... |
Use the ll (el-el) long-long modifier with the u (unsigned) conversion.
printf("%llu", 285212672); |
Non-standard things are always strange :)
for the long long portion
under GNU it's `L`, `ll` or `q`
and under windows I believe it's `ll` only |
[OmniAudit][1] is a commercial package which implments auditng across an entire database.
A free method would be to write a trigger for each table which addes entries to an audit table when fired.
[1]: http://www.krell-software.com/omniaudit/index.asp |
I believe you'd need to perform a separate query to accomplish that unfortionately.
I was able to accomplish this at my previous position using some help from this page:
[Paging in DotNet 2.0][1]
They also have it pulling a row count seperately.
[1]: https://web.archive.org/web/20210510021915/http://aspne... |
Karl is absolutely correct, there is no need to set objects to null after use. If an object implements IDisposable, just make sure you call IDisposable.Dispose() when you're done with that object (wrapped in a try..finally, or, a using() block). But even if you don't remember to call Dispose, the finaliser method on th... |
Karl is absolutely correct, there is no need to set objects to null after use. If an object implements IDisposable, just make sure you call IDisposable.Dispose() when you're done with that object (wrapped in a try..finally, or, a using() block). But even if you don't remember to call Dispose, the finaliser method on th... |
The problem with the applet approach mentioned is that unless you have the end user modify their java security properties your applet will not have permission to save to the hard drive.
It may be possible using [Java Web Start](http://java.sun.com/developer/technicalArticles/Programming/jnlp/) (aka JNLP). I think... |
You could use the IISReset command line tool to stop/restart iis. So you could write a simple batch file to stop iis, copy your files, and then restart iis. I'm not sure how to integrate this with the VS publish feature however. |
Don't you need to recompute the size of the scrollBox after the layout? |
Haskell:
My favorite general, less academic tutorial:
1. <a href="http://en.wikibooks.org/wiki/Haskell">The Haskell wikibook</a> which contains all of the excellent Yet Another Haskell Tutorial. (This tutorial helps with specifics of setting up a Haskell distro and running example programs, for example.)
Funct... |
<b>Haskell</b>:
My favorite general, less academic online tutorials:
1. <a href="http://en.wikibooks.org/wiki/Haskell">The Haskell wikibook</a> which contains all of the excellent Yet Another Haskell Tutorial. (This tutorial helps with specifics of setting up a Haskell distro and running example programs, for exa... |
`readelf` will indeed help. You can use the `-S` option; that will show the sizes of all sections. `.text` is (the bulk of) your executable code. `.data` and `.rodata` is your static data. There are other sections too, some of which are used at runtime, others only at link time. |
@[Adam Davis][1]: Uhhh actually Adam, VSS is a horrible source control system. It has a long history of corrupting history and losing data. It is terrible at merging, doesn't handle multiple developers well and is very slow. Also the history is poor. Microsoft don't really support it any more, you'll note that they nev... |
Just extending this out slightly from the original question, there are some of us doing Delphi Windows development work on virtual machines, too.
I've got a MacBook Pro (1st gen) with a couple of gigs of ram, and a recent iMac (with 4 gigs of ram). I've had more luck than xanadont with external drives, running a co... |
So after some research, here is what I found - a solution acceptable by the major search providers: [google][2] , [yahoo][1] & msn (I could on find a validator here) :
User-Agent: *
Disallow: /*
Allow: /?okparam=
Allow: /$
The trick is using the $ to mark the end of URL.
[1]: http://hel... |
I Am Not Getting the Result I Expect Using readLine() in Java |
|java|java-io| |
I am using the code snippet below, however it's not working quite as I understand it should.
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
try {
line = br.readLine();
while(line != null) {
System.out.... |
|linux|nfs|nfsclient| |
I have an NFS-mounted directory on a Linux machine that has hung. I've tried to force an unmount, but it doesn't seem to work:
$ umount -f /mnt/data
$ umount2: Device or resource busy
$ umount: /mnt/data: device is busy
If I type "`mount`", it appears that the directory is no longer mounted, but i... |
You might try a lazy unmount. umount -l |
I highly encourage you to use an ORM tool. Even simple projects can make use of ORM quickly and quietly... in particular, look at [Castle][1]'s [ActiveRecord][2] tool (which sits on top of NHibernate to simplify model declaration).
[1]: http://www.castleproject.org/index.html
[2]: http://www.castleproject.org... |
How do I create a base page in WPF? |
|wpf| |
I have decided that all my WPF pages need to register a routed event. Rather than include
public static readonly RoutedEvent MyEvent= EventManager.RegisterRoutedEvent("MyEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(BasePage));
on every page, I decided to create a base page (named BasePa... |
|.net|wpf| |
How are you starting the command shell? With the TaskManager?
I suspect you might be starting it from Explorer - if I remember correctly, this could meen that you are inheriting the parent processes (Windows Explorer in this case) PATH variable. Since that was set before your installer ran, you see the old value.
... |
I think this depends on how you are starting the new Command shell. For example, when you change the PATH environment variable under System properties, the change isn't reflected until you open a new Command prompt. I think when you launch a new "cmd" process (from the Run dialog for example), you get a fresh copy of a... |
http://support.microsoft.com/kb/310519 says that for system environment variables (which PATH is one of) requires a restart, although I have a feeling that logging off and on may be enough. |
I'm not sure on this one, but looking at your error, I would try to define the base class with just c# (.cs) code - do not create one with XAML, just a standard .cs file that extends the WPF Page class. |
I use TortoiseSVN with VFP, and it mostly-seamlessly handles the case flipping. The only time it doesn't is if I have the file open in the IDE when I try to do the commit: the file lock VFP holds confuses it. Is this where your problem comes in, or are there other issues?
I did a presentation at FoxForward last year... |
rix0rrr hit on it a bit, in that many tools are a pain to set up. Of course, I have my own solution to this problem that has been working quite well for the past few years. It's a project called [dbFacile][1]
I also wrote a bit of a [usage comparison][2] of the tools I found a few years ago. It's incomplete, but mig... |
Something like this, perhaps:
<pre><code>
<?php
//Input file
$file = "myImage.png";
$img = ImageCreateFromPNG($file);
//Dimensions
$width = imagesx($img);
$height = imagesy($img);
$max_width = 300;
$max_height = 300;
$percentage = 1;
//Image scaling calculations
if ... |
You'll want to have "When the job completes" marked in your notifications page on the job's properties.
Just go to that dropdown and switch it to job completion instead of failure (which is on the screenshot).
![alt text][1]
[1]: http://uploader.ws/upload/200808/notifications.png
You'll also want to ma... |
How do people choose product names? |
|business|name| |
I flatter myself that I'm a good programmer, and can get away with graphic design. But something I'm incapable of doing is coming up with good names - and it seems neither are the people I work with. We're now in the slightly ludicrous situation that the product we've been working on for a couple of years is being inst... |
> What would you recommend?
XMPP through BOSH
There's no need to invent your own message format and transport protocol when somebody else has. If you try, it'll slowly grow to be just as complex as BOSH but without the benefit of third-party library support or standardization. |
$(this).corner();
See: http://www.methvin.com/jquery/jq-corner-demo.html |
You shouldn't ever really need to do this. Most software that **claims** to require the default instance (like Great Plains or Dynamics) doesn't actually.
If you repost with your situation (installed X, then Y, but need to accomplish Z) I bet you'll get some good workarounds. |
+1 for SQL Server Compact. It's free and there's no 'engine' in the sense of a full-time service, but you do have to deploy a runtime (it's just two .dll files). |
To the best of my knowledge, you can attach directly to the MDF (called a "user instance", rather than attaching the MDF to a "server instance") only if SQL Server Express is installed on that machine. So your machine that has MySql on it would also have to run SQL Server Express. |
Redmine ran fine on our Windows build server from the command line, sans IDE, using Mongrel and SQLite. Granted, ours isn't a VPS, but at any rate Linux isn't required for this app.
|
Ok, I worked around this. I made a custom ActionResult (HttpForbiddenResult) and custom ActionFilter (NoFallBackAuthorize).
To avoid redirection, HttpForbiddenResult marks responses with status code 403. FormsAuthentication doesn't catch responses with this code so the login redirection is effectively skipped. The N... |
Experience with SVN vs. Team Foundation Server? |
|svn|subversion|tfs|teamfoundationserver|sourcecontrol| |
A few months back my team switched our source control over to [Subversion][1] from [Visual SourceSafe][2], and we haven't been happier. Recently I've been looking at [Team Foundation Server][3], and at least on the surface, it seems very impressive. There is some great integration with Visual Studio, and lots of grea... |
|python|podcast| |
How to send email from a program _without_ using a preexisting account? |
|.net|email|smtp| |
I'd like my program to be able to email me error reports. How can I do this without hard-coding a username/password/SMTP server/etc. into the code? (Doing so would allow users to decompile the program and take over this email account.)
I've been told you could do some stuff with telneting to port 25, but I'm very fu... |