instruction stringlengths 0 30k ⌀ |
|---|
There are a couple ways, create an action for each step of the wizard process, or create a parameter that is passed in to the action method. Like *step* that will allow you to know what the state of the wizard is in. |
Since hard drives are very cheap these days, I would suggest buying a larger hard drive and installing VS on that drive.
You should never run your OS hard drive close to max capacity, this can seriously reduce the performance of your system.
Also, you may be able to install VS but I'm quite sure it'll use alot of disk space during install (temp files) and while you actually use VS (again temp files). |
It's all about the purpose of the DB Layer.
If you use an instance to access the DB layer, you are allowing multiple versions of that class to exist. This is desirable if you want to use the same DB layer to access multiple databases for example.
So you might have something like this:
DbController acrhive = new DbController("dev");
DbController prod = new DbController("prod");
Which allows you to use multiple instances of the same class to access different databases.
Conversely you might want to allow only one database to be used within your application at a time. If you want to do this then you could look at using a static class for this purpose. |
It depends which model you subscribe to. ORM (Object Relational Model) or Interface Model. ORM is very popular right now because of frameworks like nhibernate, LINQ to SQL, Entity Framework, and many others. The ORM lets you customize some business constraints around your object model and pass it around with out actually knowing how it should be committed to the database. Everything related to inserting, updating, and deleting happens in the object and doesn't really have to worry the developer too much.
The Interface Model like the Enterprise Data Pattern made popular by Microsoft, requires you to know what state your object is in and how it should be handled. It also requires you to create the necessary SQL to perform the actions.
I would say go with ORM. |
Mozilla's Taras Glek worked the last year or two on C++ analysis and code rewriting tools. His blog is at <http://blog.mozilla.com/tglek/>, you can find links to the tools they created there. They are of course free and open-source. No GUI, but I thought I'd link it in case it's interesting to anybody. |
Joel also mentioned RedGate in [podcast #11][1]
[1]: http://blog.stackoverflow.com/2008/06/podcast-11/ |
I like a single object to be correlated to a single record in the database, i.e. an object must be instantiated. This is your basic [ActiveRecord](http://martinfowler.com/eaaCatalog/activeRecord.html) pattern. In my experience, the one-object-to-one-row approach creates a much more fluid and literate presentation in code. Also, I like to treat objects as records and the class as the table. For example to change the name of a record I do:
objPerson = new Person(id)
objPerson.name = "George"
objPerson.save()
while to get all people who live in Louisiana I might do
aryPeople = Person::getPeopleFromState("LA")
There are plenty of criticisms of Active Record. You can especially run into problems where you are querying the database for each record or your classes are tightly coupled to your database, creating inflexibility in both. In that case you can move up a level and go with something like [DataMapper](http://martinfowler.com/eaaCatalog/dataMapper.html).
Many of the modern frameworks and [ORM's](http://en.wikipedia.org/wiki/Object-relational_mapping) are aware of some of these drawbacks and provide solutions for them. Do a little research and you will start to see that this is a problem that has a number of solutions and it all depend on your needs. |
Visual Studio 2008 ASP.NET projects has debugging enabled by default. You can set breakpoints within your .js file while the website/web app project is run in the ASP.NET debug server. |
Unless your SSL certificate is the "wildcard" or multi-site kind, then I don't think this will work. The rewrite will display in the browser and the name in the address bar must be valid against the certificate, or your users will see a security error (which they can always accept and continue, but that doesn't sound like what you'd like).
More [here](http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html#vhosts). |
[awk](http://www.grymoire.com/Unix/Awk.html) |
Aha, I was really just testing everyone once again! :) The real answer is, you rarely need to iterate the datagrid. Because even when binding to an ArrayList, the binding is 2 way. Still, it is handy to know how to itereate the grid directly, it can save a few lines of code now and then.
But NotMyself and Orion gave the better answers: Convince the stakeholders to move up to a higher version of C#, to save development costs and increase maintainability and extensability. |
From memory SSRS has [built in logging][1] for this exact situation
[1]: http://msdn.microsoft.com/en-us/library/ms159110.aspx |
Have a look at the ExecutionLog table in the ReportServer database. This contains information on who ran what report and with what parameters.
I'm not sure how this is going to work without Windows authentication though, as it'll have no way of knowing who's running what report. |
Keep in mind that the Rewrite engine only kicks in once the HTTP request has been received - which means you would still need a certificate, in order for the client to set up the connection to send the request over!
However if the backup machine will appear to have the same hostname (as far as the client is concerned), then there should be no reason you can't use the same certificate as the main production machine. |
I have to say that I don't use the hourly recurrence feature as really how many people have events that repeat in the same day? I could see if someone however was to schedule when they needed to take a particular medicine at recurring times throughout the day.
I would say support full features in the application itself, but provide a warning when they go to export the calendar that all event details may not work as expected or find a way to export in a different manner for Outlook alone that does provide the hourly recurrence feature. |
I prefer using [FireBug](http://getfirebug.com/) for projects I can't use 2008 on. |
This should get you started. In Visual Studio, choose "File Open..." then "File...". Then pick the Shel32.dll. A folder tree should be opened, and you will find the icons in the "Icon" folder.
To save an Icon, You can right click on the icon in the folder tree and choose "Export". |
I think keep it simple and don't over think it. Don't over abstract and layer too much. Just keep it neat, and as it grows, refactoring it is trivial. One of the best features of IDEs is refactoring, so why not make use of it and save you brain power for solving problems that are related to your app, rather then meta issues like code organisation. |
I've finally gotten my "fully automated data back-up strategy" down to a fine art. I never have to manually intervene, and I'll never lose another harddrive worth of data. If my computer dies, I'll always have a full bootable back-up that is no more than 24 hours old, and incremental back-ups no more than an hour old. Here are the details of how I do it.
My only computer is a 160 gig MacBook running OSX Leopard.
On my desk at work I have 2 external 500 gig harddrives.
One of them is a single 500 gig partition called "External".
The other has a 160 gig partition called "Clone" and a 340 gig partition called TimeMachine.
TimeMachine runs whenever I'm at work, constantly backing up my "in progress" files (which are also committed to Version Control throughout the day).
Every weekday at 12:05, SuperDuper! automatically copies my entire laptop harddrive to the "Clone" drive. If my laptop's harddrive dies, I can actually boot directly from the Clone drive and pick up work without missing a beat -- giving me some time to replace the drive (This HAS happened to me TWICE since setting this up!). (Technical Note: It actually only copies over whatever has changed since the previous weekday at 12:05... not the entire drive every time. Works like a charm.)
At home I have a D-Link DNS-323, which is a 1TB (2x500 gig) Network Attached Storage device running a Mirrored RAID, so that everything on the first 500 gig drive is automatically copied to the second 500 gig drive. This way, you always have a backup, and it's fully automated. This little puppy has a built-in Dynamic DNS client, and FTP server.
So, on my WRT54G router, I forward the FTP port (21) to my DNS-323, and leave its FTP server up.
After the SuperDuper clone has been made, rSync runs and synchronizes my "External" drive with the DNS-323 at home, via FTP.
That's it.
Using 4 drives (2 external, 2 in the NAS) I have:
1) An always-bootable complete backup less than 24 hours old, Monday-Friday
2) A working-backup of all my in-progress files, which is never more than 30 minutes old, Monday-Friday (when I'm at work and connected to the external drives)
3) Access to all my MP3s (170GB) at documents at work on the "External" and at home on the NAS
4) Two complete backups of all my MP3s and documents on the NAS (External is original copy, both drives on NAS are mirrors via ChronoSync)
Why do I do all of this?
Because:
1) In 2000, I dropped a 40 gig harddrive 1 inch, and it cost me $2500 to get that data back.
2) In the past year, I've had to take my MacBook in for repair 4 times. One dead harddrive, two dead motherboards, and a dead webcam. On the 4th time, they replaced my MacBook with a newer better one at no charge, and I haven't had a problem since.
Thanks to my daily backups, I didn't lose any work, or productivity. If I hadn't had them, though, all my work would have been gone, along with my MP3s, and my writing, and all the photos of my trips to Peru, Croatia, England, France, Greece, Netherlands, Italy, and all my family photos. Can you imagine? I'm sure you can, because I bet you have a pile of digital photos sitting on your computer right now... not backed-up in any way. |
As for any remoting architecture, you'll want to avoid loading a full object graph "down the wire" in an uncontrolled way (unless you have a trivially small number of objects).
The [Wikipedia article][1] has the standard techniques pretty much summarised (and in C#. too!). I've used both ghosts and value holders and they work pretty well.
To implement this kind of technique, make sure that you separate concerns strictly. On the server, your service contract implementation classes should be the only bits of the code that work with data contracts. On the client, the service access layer should be the only code that works with the proxies.
Layering like this lets you adjust the way that the service is implemented relatively independently of the UI layers calling the service and the business tier that's being called. It also gives you half a chance of unit testing!
[1]: http://en.wikipedia.org/wiki/Lazy_loading |
Here's an example from one of my pages:
UltraWebGrid uwgMyGrid = new UltraWebGrid();
uwgMyGrid.Columns.Add("colTest", "Test Dropdown");
uwgMyGrid.Columns.FromKey("colTest").Type = ColumnType.DropDownList;
uwgMyGrid.Columns.FromKey("colTest").ValueList.ValueListItems.Insert(0, "ONE", "Choice 1");
uwgMyGrid.Columns.FromKey("colTest").ValueList.ValueListItems.Insert(0, "TWO", "Choice 2"); |
Here's an example from one of my pages:
UltraWebGrid uwgMyGrid = new UltraWebGrid();
uwgMyGrid.Columns.Add("colTest", "Test Dropdown");
uwgMyGrid.Columns.FromKey("colTest").Type = ColumnType.DropDownList;
uwgMyGrid.Columns.FromKey("colTest").ValueList.ValueListItems.Insert(0, "ONE", "Choice 1");
uwgMyGrid.Columns.FromKey("colTest").ValueList.ValueListItems.Insert(1, "TWO", "Choice 2"); |
As lomaxx mentioned, it's all about the purpose of the DB model.
I find it best to use static classes, as I usually only want one instance of my DAL classes being created. I'd rather use static methods than deal with the overhead of potentially creating multiple instances of my DAL classes where only 1 should exist that can be queried multiple times. |
Using the ACPrintManager I was able to get firefox 3 to print perfectly!
The one thing I had to add to the example was to check if stage was null, and callLater if the stage was null.
private function initPrint():void {
//if we don't have a stage, wait until the next frame and try again
if ( stage == null ) {
callLater(initPrint);
return;
}
PrintManager.init(stage);
var data:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
data.draw(myDataGrid);
PrintManager.setPrintableContent(data);
} |
How do you configure VS2008 to only open one webserver in a solution with multiple projects? |
|visual-studio|debugging| |
Starting with 2005, VS started this behavior of when starting debugging session it spawns up a webserver for every project in a solution. I have a solution with 15 projects so it takes a while and is a waste of resources. Is there a way to configure it differently besides just using IIS? |
You should be able to expose the underlying error message by setting the following in the web.config:
customErrors mode="Off"
Could you elaborate on "and uploading the site files"? New instance of DNN? updating an existing site? upgrading DNN version? If upgrade or update -- what files are you adding/overwriting?
Also, when using GoDaddy, can you check to verify that the web site's identity (network service or asp.net machine account depending on your IIS version) has sufficient permissions to the website's file system? It should have modify permissions and these may need to be reapplied if you are overwriting files.
* IIS6 (XP, Server 2000, 2003) = ASP.Net Machine Account
* IIS7 (Vista, Server 2008) = Network Service |
PostGRESQL's phppgadmin Reports Database |
|database|php|postgresql|phppgadmin| |
phppgadmin comes with instructions for creating a reports database on the system for use with phppgadmin. The instructions describe how to set it up, but do not really give any indication of what its purpose is, and the phppgadmin site was not very helpful either.
It seems to allow you to store SQL queries, so is it for storing admin queries accessing tables like pg_class etc? |
It is possible to remove registry keys using a .reg file, although I'm not sure how well it's documented. Here's how:
REGEDIT4
[-HKEY_CURRENT_USER\Software\<otherpath>]
The `-` in front of the key name tells `Regedit` that you want to remove the key.
To run this silently, type:
regedit /s "myfile.reg" |
Well... It looks like you have three options.
1. In your batch file, issue a tf get at each directory branch you want.
2. reorganize your solution so that all of the dependencies are under the same root path.
3. Use the visual way of right clicking on the loaded project and issuing the get command.
The only time it's actually solution aware is when the project is loaded in the IDE; or when it's loaded by the build servers. |
@Hershi: the problem with that approach is that each instance of each derived class has a copy of the data, which may be expensive in some way.
Perhaps you could try something like this (I'm spit-balling without a compiling example, but the idea should be clear).
<pre><code>
class BaseClass {
public:
BaseClass() : m_desc(0) {}
string GetName() const { return m_desc->name; }
int GetId() const { return m_desc->Id; }
X GetX() const { return m_desc->X; }
virtual void UseClass() = 0;
protected:
Descriptor * desc;
};
class DerivedClass : public BaseClass {
public:
DerivedClass() : BaseClass() {
if(s_desc == 0) {
DerivedClass::s_desc = new Descriptor("abc", 1,...)
}
m_desc = s_desc;
virtual void UseClass() { /* do something */ }
private:
static Descriptor * s_desc;
};
Descriptor * DerivedClass::s_desc = 0;
</code></pre> |
@Hershi: the problem with that approach is that each instance of each derived class has a copy of the data, which may be expensive in some way.
Perhaps you could try something like this (I'm spit-balling without a compiling example, but the idea should be clear).
<pre><code>
#include <iostream>
#include <string>
using namespace std;
struct DerivedData
{
DerivedData(const string & word, const int number) :
my_word(word), my_number(number) {}
const string my_word;
const int my_number;
};
class Base {
public:
Base() : m_data(0) {}
string getWord() const { return m_data->my_word; }
int getNumber() const { return m_data->my_number; }
protected:
DerivedData * m_data;
};
class Derived : public Base {
public:
Derived() : Base() {
if(Derived::s_data == 0) {
Derived::s_data = new DerivedData("abc", 1);
}
m_data = s_data;
}
private:
static DerivedData * s_data;
};
DerivedData * Derived::s_data = 0;
int main()
{
Base * p_b = new Derived();
cout << "Derived word is " << p_b->getWord() << endl;
}
</code></pre>
Regarding the follow-up question on deleting the static object: the only solution that comes to mind is to use a smart pointer, something like the [Boost shared pointer][1].
[1]: http://http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/smart_ptr.htm |
Verilog automatic task |
|verilog| |
What does it mean if a task is declared with the automatic keyword in Verilog?
task automatic do_things;
input [31:0] number_of_things;
reg [31:0] tmp_thing;
begin
// ...
end
endtask;
Note: This question is mostly because I'm curious if there are any hardware programmers on the site. :) |
Take a look at Perforce ([www.perforce.com][1]), particularly if you are managing these files in the context of development projects. It is a code-oriented system, but it supports binary files well and has a Photoshop plugin. P4 isn't free, but it is worth every penny if you need professional-grade SCM - it is solid, fast, flexible and easy to use. (I am a very satisfied customer.)
[1]: http://www.perforce.com |
C++ has templates. Java has generics, which look kinda sorta like C++ templates, but they're very, very different.
Templates work, as the name implies, by providing the compiler with a (wait for it...) template that it can use to generate type-safe code by filling in the template parameters.
Generics, as i understand them, work the other way around: the type parameters are used by the compiler to verify that the code using them are type-safe, but the resulting code is generated without types at all.
Think of C++ templates as a *really good* macro system, and Java generics as a tool for automatically generating typecasts. |
You need to encapsulate it into another object[] array, like this:
Foo(new Object[] { new object[]{ (object)"1", (object)"2" }});
|
There is a big difference between them. In C++ you don't have to specify a class or an interface for the generic type. That's why you can create truly generic functions and classes, with the caveat of a looser typing.
<typename T> T sum(T a, T b) { return a + b; }
The method above adds two objects of the same type, and can be used for any type T that has the "+" operator available.
In Java you have to specify a type if you want to call methods on the objects passed, something like:
<T extends Something> T sum(T a, T b) { return a.Add ( b ); }
In C++ generic functions/classes can only be defined in headers, since the compiler generates different functions for different types (that it's invoked with). So the compilation is slower. In Java the compilation doesn't have a major penalty, but Java uses a technique called "erasure" where the generic type is erased at runtime, so at runtime Java is actually calling ...
Something sum(Something a, Something b) { return a.Add ( b ); }
So generic programming in Java is not really useful, it's only a little syntactic sugar to help with the new foreach construct. |
The term lazy loading is usually used when talking about object relational mappers. If you use ADO.NET directly you always get eager loading (ie it always loads just what you specify).
OR-mappers like nHibernate support returning proxy objects that get "filled in" with the right data only when you access the data. That way you only load the data that you really use. This is a usefull feature when you specify a lot of relations between objects that can get loaded from the database, you don't want the OR-mapper to load all the related objects and the objects related to the related objects and so on. That can result in your whole database getting loaded.
This problem can be prevented by carefull design of your object model too. (using aggregates and only loading aggregate roots like in domain driven design is a way to get around this without using lazy loading).
Lazy loading can result in the or mapper doing lots of small database accesses instead of retrieving all the data you need once. This can result in performance problems too. |
|hardware|specman|eda| |
No specific ideas on this problem, I'm afraid - but you could look into a '[genetic algorithm][1]' (which would go *something* like this)...
Place the lengths to cut in a random order and give that order a score based on how good a match it is to your ideal solution (0% waste, presumably).
Then, iteratively make random alterations to the order and re-score it. If the score is higher, ditch the result. If the score is lower, keep it and use it as the basis for your next calculation. Keep going until you get your score within acceptable limits.
[1]: http://en.wikipedia.org/wiki/Genetic_algorithm |
Hm, I'm not sure what you're trying to accomplish.
Usually implementing NTLM on an internal site is as simple as unchecking "Enable Anonymous Access" in "Authentication and Access Control" in the "Directory Security" tab of website properties in IIS. If that is cleared, then your web application users will see a pop-up NTLM dialog.
There's no need for you to write any code that interfaces with Active Directory. IIS takes care of the authentication for you.
Can you be more specific about what you're trying to do? |
Why don't you use LinqToSql - everything you need is done automatically. For the sake of being general you can use any other [ORM tool](http://en.wikipedia.org/wiki/Object-relational_mapping) for .NET |
I would call reader.GetOrdinal for each field name before starting the while loop. Unfortunately GetOrdinal throws an IndexOutOfRangeException if the field doesn't exist, so it won't be very performant.
You could probably store the results in a Dictionary<string, int> and use its ContainsKey method to determine if the field was supplied. |
As I understand it.
NTLM is one of IIS built in authentication methods. If the the Host is registered on the domain of said active directory, it should be automatic. One thing to watch out for is the username should be in one of two formats.
- domain\username
- username@domain.tld
If you are trying to go against a different active directory you should be using a forms style authentication and some LDAP code.
If you are trying to do the Intranet No Zero Login thing with IIS Integrated authentication
- the domain needs to be listed as a trusted site in IEx browser
- or use a url the uses the netbios name instead of the DNS name.
- for it to work in firefox read [here][1]
[1]: https://calshare.berkeley.edu/Resources0/Pages/FirefoxonWindows.aspx |
In my scenario, I am not using the built-in "save" button. I have a data connection that I use to "post" the data to another list.
Yes, that's what I mean by site-specific. I don't think you can use localhost 'cos then when a user saves the form, it'll try to post to the user's computer (i.e. localhost). I have tried to use relative paths but that doesn't seem to work. |
From what i've tried (and are still up to do), a good addition to an erlang dev. environment would be a virtual machine running ubuntu/yaws/erlang. Perhaps [Erlyweb][1] (erlang/yaws framework) would be nice checking out too.
[Ciaran][2]'s posts (this would be the first of his "series") about his erlang install is nice, as he details the steps in setting up the server (and other stuff like xmpp with jabberlang).
[1]:http://feeds.feedburner.com/10xSoftwareDevelopment?format=xml
[2]:http://blog.ciarang.com/posts/compiling-erlang-on-ubuntu |
For the asynchronous bit, I would suggest checking into java.util.concurrent, and especially the Future<T> interface. The future interface is used to represent objects which are not ready yet, but are beeing created in a seperate thread. You say that objects can be modified at any time by a third party, but I would still suggest you use immutable return objects here, and instead have a seperate thread/event log you can subscribe to to get noticed when objects expire. I have little programming with UIs, but I believe using Futures for asynchronus calls would let you have a responsive gui, rather than one that was waiting for a server reply.
For the queries I would suggest using method chaining to build the query object, and each object returned by method chaining should be Iterable. Similar to how Djangos model is. Say you have QuerySet which implements Iterable<Song>. You can then call allSongs() which would return a result iterating over all Songs. Or allSongs().artist("Beatles"), and you would have an iterable over all Betles songs. Or even allSongs().artist("Beatles").years(1965,1967) and so on.
Hope this helps as a starting place. |
How do I avoid read locks in my database? |
|sql|database|performance|locking| |
Answers for multiple databases welcome! |
The operating system takes care of multi-threading when the virtual machine is using native threads (as opposed to green-threads), and you can't specify low level details, like choosing a processor for a certain thread. It is better that way because you usually have many more threads than you have processors available, so the operating system needs to do time-slicing to give all threads a chance to run.
That being said, you can set threads priorities if you have a critical task, and a threading API usually provides this possibility. See the Java API for example: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#setPriority(int)
PS: there's something broken in the parsing engine ... I had to add the above link as plain text |
In SQL Server you can use the with(nolock) keyword in your select statements. For example:
Select table1.columna, table2.columna
from table1 with(nolock), table2 with(nolock)
Make sure to specify with(nolock) for each table/view in the query.
|
CSS - Make divs align horizontally |
|css|xhtml| |
I have a container div with a fixed width and height, with overflow: hidden.
I want a horizontal row of float: left divs within this container. Divs which are floated left will naturally push onto the 'line' below after they read the right bound of their parent. This will happen even if the height of the parent should not allow this. This is how this looks:
![Wrong][1]
How I would like it to look:
![Right][2]
Note: the effect I want can be achieved by using inline elements & white-space: no-wrap (that is how I did it in the image shown). This, however, is no good to me (for reasons too lengthy to explain here), as the child divs need to be floated block level elements.
Help please!
[1]: http://img530.imageshack.us/img530/9063/wrongoh7.png
[2]: http://img391.imageshack.us/img391/8239/rightlk3.png |
Use for the phppgadmin Reports Database? |
|php|database|postgresql|phppgadmin| |
Nope, you must save in order for the EntLib (and, I suspect, any other tool) to see the changes. |
@svrist If you don't know the schema the XStream solution probably isn't the way to go. At least XStream is on your radar now -- might come in handy in the future! |
Yes, drag and drop is different in AIR. I HATE that! It takes a lot of playing around to figure out how to get things to work the same as custom dnd that was built in flex.
As for the coordinates, maybe play around with localToContent, and localToGlobal methods. They may help in translating the coordinates to something useful.
Good luck. I will let you know if I think of anything else.
|
If you are looking for performance, I tested a few hash keys and
I recommend [Bob Jenkin][1]'s hash function. It is both crazy fast
to compute and will give as little collisions as the cryptographic
hash you used until now.
I don't know C# at all and I don't know if it can link with C, but
here is its [implementation][2] in C.
[1]: http://burtleburtle.net/bob/hash/doobs.html
[2]: http://burtleburtle.net/bob/c/lookup3.c |
URL Redirection for SSL virtual hosts |
|apache|mod-rewrite|https| |
What is the best way to transparently rewrite a URL over an SSL connection with Apache 2.2?
Apache 2 does not natively support multiple name-based virtual hosts for an SSL connection and I have heard that mod_rewrite can help with this. I would like to do something like this:
I have set up the server so that the sites can be accessed by
https://secure.example.com/dbadmin
but I would like to have this as https://dbadmin.example.com
How do I set it up so that the Rewrite rule will rewrite dbadmin.example.com to secure.example.com/dbadmin, but without displaying the rewrite on the client's address bar (i.e. the client will still just see dbadmin.example.com), all over https? |
Using mod_rewrite to Mimic SSL Virtual Hosts? |
|apache|https|mod-rewrite| |
The hash code of an object shouldn't be unique.
The checking rule is: hash codes are equal? Then call the full (slow) Equals method
Hash codes are not equal? Then the two items are definitely not equal.
All you want is a `GetHashCode` algorithm that splits up your collection into roughly even groups - it shouldn't form the key as the `HashTable` or `Dictionary<>` will need to use the hash to optimise retrieval.
How long do you expect the data to be? How random? If lengths vary greatly (say for files) then just return the length. If lengths are likely to be similar look at a subset of the bytes that varies.
GetHashCode should be a lot quicker than Equals, but doesn't need to be unique. |
I've never used (or even heard of) Stripes.
Regardless, there's a book from [The Pragmatic Bookshelf][1] called [Stripes: ...and Java web development is fun again][2] that may be worth checking out. You could also check out the Stripes [mailing list archive][3].
[1]: http://www.pragprog.com/
[2]: http://www.pragprog.com/titles/fdstr/stripes
[3]: https://sourceforge.net/mail/?group_id=145476 |
Without doubt, you should purchase Don Syme's excellent book "Expert F#". The book is very well written and is suitable for both beginners and experts alike. In it, you'll find both introductory material and much more challenging material too. At nearly 600 pages it is good value for money.
I found that it taught me a lot of useful techniques for writing more functional C# as well as providing all the reference material I needed to get started writing Windows hosted F# applications.
The book is published by Apress and has an accompanying web site at:
http://www.expert-fsharp.com/default.aspx
|
I've been dabbling in Cocoa for the past couple years, and recently picked up Fritz Anderson's "[Xcode 3 Unleashed][1]." Highly recommended for getting into Xcode — especially with some of the big changes 3.0/Leopard brought.
Don't forget Hillegass' defacto Cocoa bible, "Cocoa Programming for Mac OS X - Third Edition."
[1]: http://www.amazon.com/Xcode-3-Unleashed-Fritz-Anderson/dp/0321552636 |
One option is you can wrap it into another array:
Foo(new object[]{ new object[]{ (object)"1", (object)"2" } });
Kind of ugly, but since each item is an array, you can't just cast it to make the problem go away... such as if it were Foo(params object items), then you could just do:
Foo((object) new object[]{ (object)"1", (object)"2" });
Alternatively, you could try defining another overloaded instance of Foo which takes just a single array:
void Foo(object[] item)
{
// This may be a recursive call, so it may not
// work, but the overloading should work
Foo(new object[]{ item });
} |
One option is you can wrap it into another array:
Foo(new object[]{ new object[]{ (object)"1", (object)"2" } });
Kind of ugly, but since each item is an array, you can't just cast it to make the problem go away... such as if it were Foo(params object items), then you could just do:
Foo((object) new object[]{ (object)"1", (object)"2" });
Alternatively, you could try defining another overloaded instance of Foo which takes just a single array:
void Foo(object[] item)
{
// Somehow don't duplicate Foo(object[]) and
// Foo(params object[]) without making an infinite
// recursive call... maybe something like
// FooImpl(params object[] items) and then this
// could invoke it via:
// FooImpl(new object[] { item });
} |
A simple typecast will ensure the compiler knows what you mean in this case.
Foo((object[])new object[]{ (object)"1", (object)"2" }));
Bit of an odd semantic though, I'll agree. |
A simple typecast will ensure the compiler knows what you mean in this case.
Foo((object)new object[]{ (object)"1", (object)"2" }));
As an array is a subtype of object, this all works out. Bit of an odd semantic though, I'll agree.
Edit: Woops, typoed my example code. |
I'm still fiddling with this -- no answer yet, or even a clear direction, but some of this random assortment of facts might be useful to someone..
**Meta: Is there any way to mark "read more" in an answer? Sorry in advance for all the scrolling this answer will cause!**
The code is 708 digits long. Prime factorization: 2 2 3 59. Unless they're being tricky by padding the ends, the chunk size must be 1, 2, 4, 6, or 12; the higher factors are silly. This assumes, of course, that the code is based on concatenated chunks, which may not be the case.
Mike Stone suggested a chunk size of 3. Here's the distribution for that:
<pre>
Number of distinct chunks: 64
Number of chunks: 236 (length of message)
275: ###
279: #######
282: ####
283: #
284: ####
285: ##
286: #
287: ###
288: #
289: ###
292: #
293: ####
297: #
323: #############################
324: #######
325: #######
326: ####
327: ####
328: ##
329: #####
332: ###
333: ###########
334: ###
335: ######
336: ###
337: #
338: ####
339: ###
342: #
343: ##
344: ###
345: #
346: ###
347: ##
348: ###
349: ###
352: ####
353: #
354: ##
363: ##
364: #######
365: #####
366: #####
367: ##
368: ###
369: ##
372: ###
373: ##
374: ##
375: ###
376: #######
377: ####
378: ##
382: ###
383: ###
384: ###
385: ####
387: ##
388: ######
389: ##
392: ###
393: ####
394: ###
449: #
</pre>
If it's base64 encoded then we might have something ;) but my gut tells me that there are too many distinct chunks of length 3 for plain English text. There is indeed that odd blip for the symbol "323" though.
Somewhat more interesting is a chunk size of 2:
<pre>
Number of distinct chunks: 49
Number of chunks: 354 (length of message)
22: ##
23: ########################
24: #####
25: ######
26: #
27: ######
28: #########
29: ####
32: ##################################
33: ################################################
34: ###########
35: ########
36: ##############
37: ############
38: ##################
39: ####
42: ##
43: ###########
44: ###
45: #
46: #
47: #
49: ##
52: #
53: #########
54: ##
62: #
63: #############
64: ####
65: ###
66: ##
67: ##
68: #
72: ###
73: ############
74: #
75: ####
76: #####
77: #
79: ####
82: ######
83: ###########
84: #####
85: ####
88: ####
89: #
92: #########
93: ################
94: ##
</pre>
As for letter frequency, that's a good strategy, but remember that the text is likely to contain spaces and punctuation. Space might be the most common character by far!
Meta: This question re-asks a question found elsewhere. Does that count as homework? :)
|
I'd suggest you use a **Assymmetric Key Encryption** to encrypt your configuration file, wherever they are stored, inside the executable or not.
Store the "reading" key in your executable and keep to yourself the "writing" key. So no one but you can modify the configuration.
**It's not hard** there are plenty of libraries available these days. |
I'd suggest you use a **Assymmetric Key Encryption** to encrypt your configuration file, wherever they are stored, inside the executable or not.
If I remember correctly, RSA is one the variants.
For the explanation of it, see [Public-key cryptography][1] on Wikipedia
Store the "reading" key in your executable and keep to yourself the "writing" key. So no one but you can modify the configuration.
This has the advantages of:
* No-one can modify the configuration unless they have the "writing" key because any modification will _corrupt_ it entirely, even if they know the "reading" key it would takes ages to compute the other key.
* Modification guarantee.
* It's not hard - there are plenty of libraries available these days. There're also a lot of key-generation programs that can generate really, really long keys.
Do take some research on how to properly implement them though.
[1]: http://en.wikipedia.org/wiki/Public-key_cryptography |
In native code, if the corruption always occurs in the same place in memory, you can use a [data breakpoint][1] to break the debugger when that memory is changed. Unfortunately, you can not set a data breakpoint in the managed C++ environment, presumably because the GC could move the object in memory.
Not sure if this helps, but hopefully it leads you off in the right direction.
[1]: http://msdn.microsoft.com/en-us/library/350dyxd0.aspx |
MochiKit is great -- and was my first love, so-to-speak, as far as js libraries go. But I found that while MochiKit has very expressive syntax, it didn't feel nearly as comfortable to me as Prototype/Scriptaculous or jQuery did for me.
I think if you know or like python, then MochiKit is a good tool for you. |
The only way to change the instance name is to re-install - uninstall and install as default instance. |
Are null and an empty string equivalent? If they are, I would include logic in my application (or maybe a trigger if the app is "out-of-the-box"?) to force the field to be either null or '', but not the other. If you went with '', then you could set the column to NOT NULL as well. Just a data-cleanliness thing. |
How do I fix a NoSuchMethodError? |
|java| |
I'm getting a NoSuchMethodError when running my Java program. What's wrong and how do I fix it? |
This is usually caused when using a build system like [Apache Ant](http://ant.apache.org) that only compiles java files when the java file is newer than the class file. If a method signature changes and classes were using the old version things may not be compiled correctly. The usual fix is to do a full rebuild (usually "ant clean" then "ant").
Sometimes this can also be caused when compiling against one version of a library but running against a different version.
|
Also check out this [extension method I wrote][1] for use on data commands:
public static void Fill<T>(this IDbCommand cmd,
IList<T> list, Func<IDataReader, T> rowConverter)
{
using (var rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
list.Add(rowConverter(rdr));
}
}
}
You can use it like this:
cmd.Fill(products, r => r.GetProduct());
Where "products" is the IList<Product> you want to populate, and "GetProduct" contains the logic to create a Product instance from a data reader. It won't help with this specific problem of not having all the fields present, but if you're doing a lot of old-fashioned ADO.NET like this it can be quite handy.
[1]: http://www.madprops.org/blog/another-idbcommand-extension-fill/ |
Microsoft [Concurrency and Coordination Runtime](http://msdn.microsoft.com/en-us/library/bb648752.aspx) for .NET.
> The CCR is appropriate for an
> application model that separates
> components into pieces that can
> interact only through messages.
> Components in this model need means to
> coordinate between messages, deal with
> complex failure scenarios, and
> effectively deal with asynchronous
> programming.
|
You might want to have a look at the Compensating Resource Manager:
[http://msdn.microsoft.com/en-us/library/8xkdw05k(VS.80).aspx][1]
[1]: http://msdn.microsoft.com/en-us/library/8xkdw05k(VS.80).aspx |
Use the GetSchemaTable() method to retrieve the DataReader's metadata. The DataTable that is returned can be used to check if a specific column is present or not. |
Why not just have each sproc return complete column set, using null, -1, or acceptable values where you don't have the data. Avoids having to catch IndexOutOfRangeException or re-writing everything in LinqToSql. |
I think most of the answers here take a designer's point of view. On a small-to-medium project it might seem like an overhead to synchronize code and CSS/HTML and make them standards-compliant and clean. A designer's way to do that is to have full control over rendered HTML. But there's many ways to have that full control in ASP.NET. And for me, having the required HTML in the aspx/ascx file is the most non-scalable and dirty way to do it. If you want to style controls through CSS, you can always set a class server-side through the CssClass property. If you want to access them through JS, you can emit the JS with right IDs server-side again. The only disadvantage that this provides is that a dev and a designer have to work together closely. On any large project this is unavoidable anyway. But the advantages ASP.NET provides far outnumber these difficulties.
Still, if you want standards-compliant HTML, skinning support and other goodies to control rendered markup, you can always use thrid-party controls. |
Have you tried putting in the *standard library directories*? It should be picked up by the **linker** if it's in one of those directories.
For example:
/lib/
/usr/lib/
/usr/share/lib/
/usr/local/lib/ |
i assume that you are wanting get to some of the attributes that are set against the LDAP account - role - department etc.
for coldfusion check this out [http://www.adobe.com/devnet/server_archive/articles/integrating_cf_apps_w_ms_active_directory.html][1]
[1]: http://www.adobe.com/devnet/server_archive/articles/integrating_cf_apps_w_ms_active_directory.html |
I've had the same problem, and built a tool on top of Subversion that adds permission, ownership and secontext tracking, keeps the .svn directories out of the actually versioned trees, and adds a concept of layers so you can for example track all your config related to development, which you then only check out on machines you use for developing.
This has helped me organize my settings much better across the 50+ machines I log into.
[Here's the project page][1]. It's still a little rough around the edges, but we also use it at work to version system configuration for our 60+ servers.
In general, any version control system that uses some sort of metadata files to track stuff is going to cause you pain as is when actually using it.
[1]: https://thomas.apestaart.org/thomas/trac/wiki/projects/savon |
What do you mean?
Are you saying that when you go from www.mysmallwebsite.com to www.myIsv.com/myWebSite/ then the PHP session is lost?
PHP recognizes the session with an ID (alpha-numeric hash generated on the server). The ID is passed from request to request using a cookie called PHPSESSID or something like that (you can view the cookies a websites sets with the help of your browser ... on Firefox you have Firebug + FireCookie and the wonderful Web Developer Toolbar ... with which you can view the list of cookies without a sweat).
So ... PHP is passing the session ID through the PHPSESSID cookie. But you can pass the session ID as a plain GET request parameters.
So when you place the html link to the ugly domain name, assuming that it is the same PHP server (with the same sessions initialized), you can put it like this ...
www.myIsv.com/myWebSite/?PHPSESSID=<?=session_id()?>
I haven't worked with PHP for a while, but I think this will work. |