instruction
stringlengths 0
30k
⌀ |
---|
|c#|hash| |
How will a sdbm hash function (such as http://www.cse.yorku.ca/~oz/hash.html) be implemented in C# ? |
This sounds very much like my first job. Straight out of university, I was asked to design the database and business logic layer, while other people would take care of the UI. Meanwhile the boss was looking over my shoulder, unwilling to let go of what used to be his baby and was now mine, and poking his finger in it. Three years later, developers were fleeing the company and we were still X months away from actually selling anything.
The big mistake was in being too ambitious. If this is your first job, you *will* make mistakes and you *will* need to change how things work long after you've written them. We had all sorts of features that made the system more complicated than it needed to be, both on the database level and in the API that it presented to other developers. In the end, the whole thing was just far too complicated to support all at once and just died.
So my advice:
1. If you're not sure about taking on such a big job single-handed, don't. Tell your employers, and get them to find or hire somebody for you to work with who can help you out. If people need to be added to the project, then it should be done near the start rather than after stuff starts going wrong.
2. Think very carefully about what the product is for, and to boil it down to the **simplest** set of requirements you can think of. If the people giving you the spec aren't technical, try to see past what they've written to what will actually work and make money. Talk to customers and salespeople, and understand the market.
3. There's no shame in admitting you're wrong. If it turns out that the entire system needs to be rewritten, because you made some mistake in your first version, then it's better to admit this as soon as possible so you can get to it. Correspondingly, don't try to make an architecture that can anticipate every possible contingency in your first version, because you don't know what every contingency is and will just get it wrong. Write once with an eye to throwing away and starting again - you may not have to, the first version may be fine, but admit it if you do. |
You may also be interested in the output of the explain() method, which will give you an idea of how things are scored the way they are:
> [http://lucene.apache.org/java/2_2_0/api/org/apache/lucene/search/Searcher.html#explain(org.apache.lucene.search.Query,%20int)][1]
and the Explanation object:
> [http://lucene.apache.org/java/2_2_0/api/org/apache/lucene/search/Explanation.html][2]
(Ick, scary URLs.)
[1]: http://lucene.apache.org/java/2_2_0/api/org/apache/lucene/search/Searcher.html#explain(org.apache.lucene.search.Query,%20int)
[2]: http://lucene.apache.org/java/2_2_0/api/org/apache/lucene/search/Explanation.html |
What is the difference between an int and an Integer in C? |
|c| |
I was just sitting at my local Borders sipping coffee and reading (for free) 'More Joel on Software' when I came across Joel saying something about a particular type of programmer knowing the difference between an int and an Integer in C. After a quick 'brain check,' I realized, to my dismay, that I didn't know the answer. Please help. |
What is the difference between an int and an Integer in Java/C#? |
|c#|java| |
I was just sitting at my local Borders sipping coffee and reading (for free) 'More Joel on Software' when I came across Joel saying something about a particular type of programmer knowing the difference between an int and an Integer in Java/C# (Object Oriented Programming Languages). After a quick 'brain check,' I realized, to my dismay, that I didn't know the answer. Please help. |
Well, in Java an int is a primitive while an Integer is an Object. Meaning, if you made a new Integer:
Integer i = new Integer(6);
You could call some method on i:
String s = i.toString();//sets s the string representation of i
Whereas with an int:
int i = 6;
You cannot call any methods on it, because it is simply a primitive. So:
String s = i.toString();//will not work!!!
would produce an error, because int is not an object.
int is one of the few primitives in Java (along with char and some others). I'm not 100% sure, but I'm thinking that the Integer object more or less just has an int property and a whole bunch of methods to interact with that property (like the toString() method for example). So Integer is a fancy way to work with an int (Just as perhaps String is a fancy way to work with a group of chars).
I know that Java isn't C, but since I've never programmed in C this is the closest I could come to the answer. Hope this helps!
[http://java.sun.com/j2se/1.3/docs/api/java/lang/Integer.html][1]
[http://mindprod.com/jgloss/intvsinteger.html][2]
[1]: http://java.sun.com/j2se/1.3/docs/api/java/lang/Integer.html
[2]: http://mindprod.com/jgloss/intvsinteger.html |
Sign up for an account on as many major email providers as possible (gmail/yahoo/hotmail/aol/etc). If you make changes to your emails, either major rewording, changes to the code that sends the emails, changes to your email servers, etc, make sure to send test messages to all your accounts and verify that they are not being marked as spam. |
For my projects I alternate between SQL Compare from REd Gate and the Database Publishing Wizard from Microsoft which you can download free
[here][1].
The Wizard isn't as slick as SQL Compare or SQL Data Compare but it does the trick. One issue is that the scripts it generates may need some rearranging and/or editing to flow in one shot.
On the up side, it can move your schema and data which isn't bad for a free tool.
[1]: http://www.microsoft.com/downloads/details.aspx?familyid=56E5B1C5-BF17-42E0-A410-371A838E570A&displaylang=en |
I have read Working Effectively With Legacy Code, and I agree it is very useful for dealing with "untestable" code.
Some techniques only apply to compiled languages (I'm working on "old" PHP apps), but I would say most of the book is applicable to any language.
Refactoring books sometimes assume the code is in semi-ideal or "maintenance aware" state before refactoring, but the systems I work on are less than ideal and were developed as "learn as you go" apps, or as first apps for some technologies used (and I don't blame the initial developers for that, since I'm one of them), so there are no tests at all, and code is sometimes messy. This book addresses this kind of situation, whereas other refactoring books usually don't (well, not to this extent).
I should mention that I haven't received any money from the editor nor author of this book ;), but I found it very interesting, since resources are lacking in the field of legacy code (and particularly in my language, French, but that's another story). |
When is it Best to Sanitize User Input? |
|sanitization|user-input|sanitize-now|sanitize-later| |
User equals untrustworthy. Never trust untrustworthy user's input. I get that. However, I am wondering when the best time to sanitize input is. For example, do you blindly store user input and then sanitize it whenever it is accessed/used, or do you sanitize the input immediately and then store this "cleaned" version? Maybe there are also some other approaches I haven't though of in addition to these. I am leaning more towards the first method, because any data that came from user input must still be approached cautiously, where the "cleaned" data might still unknowingly or accidentally be dangerous. Either way, what method do people think is best, and for what reasons? |
|sanitization|user-input| |
|sanitization|user-input|sql-injection| |
|xss|sql-injection|user-input|sanitization| |
Subversion is not an ideal solution for binary files, regardless of how little has changed it will save a new copy each time you check it in. Moreover, although Subversion has some locking capabilities, it doesn't lock by default, which means that if two persons modify the same binary file the one that checks in the last will overwrite the other one's changes.
Also, there's no tool out there that's as integrated with the Adobe design tools as Version Cue is.
Subversion is great for text-based content, but really really not suited to the kind of files you will be working with. |
The popup window can be closed using the onClick html event as follows:
<%= submit_tag "Go!", {:onClick => "window.close()"} %> |
Flex: does painless programmatic data binding exist? |
|apache-flex|actionscript|mxml| |
I've only done a bit of Flex development thus far, but I've preferred the approach of creating controls programmatically over mxml files, because (and *please*, correct me if I'm wrong!) I've gathered that you can't have it both ways -- that is to say, have the class functionality in a separate ActionScript class file but have the contained elements declared in mxml.
There doesn't seem to be much of a difference productivity-wise, but doing data binding programmatically seems somewhat less than trivial. I took a look at how the mxml compiler transforms the data binding expressions. The result is a bunch of generated callbacks and a lot more lines than in the mxml representation. So here's the question: **is there a way to do data binding programmatically that doesn't involve a world of hurt?** |
Without collisions, you can do
M = [fieldnames(A)' fieldnames(B)'; struct2cell(A)' struct2cell(B)'];
C=struct(M{:});
And this is reasonably efficient. However, `struct` errors on duplicate fieldnames, and pre-checking for them using `unique` kills performance to the point that a loop is better. But here's what it would look like:
M = [fieldnames(A)' fieldnames(B)'; struct2cell(A)' struct2cell(B)'];
[tmp, rows] = unique(M(1,:), 'last');
M=M(:, rows);
C=struct(M{:});
You might be able to make a hybrid solution by assuming no conflicts and using a try/catch around the call to `struct` to gracefully degrade to the conflict handling case.
|
This is normally used if you need to interact with the operating system in some way, for example, to place a message in MSMQ or write to a file. It is also useful if you have some complex mathematical or financial calculations that are already implemented in .NET, and you don't want to re-write them in T-SQL. |
I think you confusing business logic with your application requirements. It's not the same thing. When someone explains the logic of his/her business it is something like:
"When a user buys an item he has to provide delivery information. The information is validated with x y z rules. After that he will receive an invoice and earn points, that gives x% in discounts for the y offers" (sorry for the bad example)
When you implement this business rules you'll have to think in secondary requirements, like how the information is presented, how it will be stored in a persistent way, the communication with application servers, how the user will receive the invoice and so on. All this requirements are not part of business logic and should be decoupled from it. This way, when the business rules change you will adapt your code with less effort. Thats a fact.
Sometimes the presentation replicates some of the business logic, mostly in validating user input. But it has to be also present in the business logic layer. In other situations, is necessary to move some business logic to the Database, for performance issues. This is discussed by Martin Fowler [here][1].
[1]: http://martinfowler.com/articles/dblogic.html |
I like to use a validation service, which doesn't necessarily care about the origin of the data to be validated. This can work in a few different ways when you get to the part about transmitting validation rules to a client (i.e. web page), but I feel the most important aspect of this is to have a single authority for the actual validation rules.
For example, if you have validation logic on your data core entities, like a collection of ValidationRule objects that are checked via a Validate method - a very typical scenario, then I would promote those same rules to the client (javascript) via a transformation.
In the ASP.NET world (the only one I can speak to) there are a couple of ways to do this. My preferred method involves creating custom validators that tie in to your UI widgets to fields (and all their validation rules) on your entities. The advantage of this is that all your validation logic can be bundled into a single validator. The down side is that your validation messages will become dense, since the validation rules are all tested at once. This can, of course, be mitigated by having your validation logic return only a mention of the first failure, etc.
This answer probably sounds sort of nebulous and unspecific, but the two points that I'd like to make are:
1. Validation should occur as close as possible to the points where data is entered and where it's committed.
2. The same validation rules should be used wherever validation occurs - if client-side validation passes, then it should never fail validation later on (pre-save business rules, foreign key violation, etc.) |
I once started a phpBB/MediaWiki login integration project. [Check it out][1].
[1]: https://damnian.svn.sourceforge.net/svnroot/damnian/phpBB3/MediaWiki/ |
I once did a phpBB/MediaWiki login integration from the phpBB side.
[Check it out][1].
[1]: https://damnian.svn.sourceforge.net/svnroot/damnian/phpBB3/MediaWiki/ |
I once did a phpBB/MediaWiki login integration from the phpBB end.
[Check it out][1].
[1]: https://damnian.svn.sourceforge.net/svnroot/damnian/phpBB3/MediaWiki/ |
Is there a built-in method to compare collections in C#? |
|c#|.net| |
I would like to compare the contents of a couple of collections in my Equals method. I have a Dictionary<string, object> and an IList<object>. Is there a built-in method to do this? |
I would like to compare the contents of a couple of collections in my Equals method. I have a Dictionary<string, object> and an IList<object>. Is there a built-in method to do this?
Edited:
I want to compare two Dictionaries and two ILists, so I think what equality means is clear - if the two dictionaries contain the same keys mapped to the same values, then they're equal. |
What is a good deployment tool for websites on Windows? |
|iis|deployment| |
I'm looking for something that can copy (preferably only changed) files from a development machine to a staging machine and finally to a set of production machines.
A "what if" mode would be nice as would the capability to "rollback" the last deployment. Database migrations aren't a necessary feature. |
I'm looking for something that can copy (preferably only changed) files from a development machine to a staging machine and finally to a set of production machines.
A "what if" mode would be nice as would the capability to "rollback" the last deployment. Database migrations aren't a necessary feature.
UPDATE: A free/low-cost tool would be great, but cost isn't the only concern. A tool that could actually manage deployment from one environment to the next (dev->staging->production instead of from a development machine to each environment) would also be ideal.
The other big nice-to-have is the ability to only copy changed files - some of our older sites contain hundreds of .asp files. |
First day is always YYYY-MM-01, isn't it? Example: `date("Y-M-d", mktime(0, 0, 0, 8, 1, 2008))`
Last day is the previous day of the next month's first day:
$date = new DateTime("2008-09-01");
$date->modify("-1 day");
echo $date->format("Y-m-d");
|
The first day of the month is always 1.
So it will become
YYYY-MM-01
the last day can be calculated as:
<?php
$num = cal_days_in_month(CAL_GREGORIAN, 8, 2003); // 31
echo "There was $num days in August 2003";
?>
|
|java|security|desktop| |
I have a project to build a voting desktop application for a class in Java. While security isn't the focus of the project, I would like to be as realistic as I can. What are some of the primary tools to integrate security into a Java application.
Edit: I'm not primarily worried about physical security, we are simply building an application not a whole system. I want to ensure votes are recorded correctly and not able to be changed or read by someone else. |
Stop the taskbar flashing |
|c#|winforms|taskbar| |
I know I can programatically make the taskbar item for a particular window start flashing when something changes, but is there any way I can stop it from flashing either programatically after a certain period of time or at least is there a keyboard shortcur I can give to my users to somehow stop the flashing? |
@Joseph, notice that the variables are 8 bits wide, while the shift is 12 bits wide. Your solution works only for <code>N <= variable size.<code>
If you can assume your array is a multiple of 4 you can cast the array into an array of uint64_t and then work on that. If it isn't a multiple of 4, you can work in 64-bit chunks on as much as you can and work on the remainder one by one.
This may be a bit more coding, but I think it's more elegant in the end. |
You would have to get in contact with Nintendo of America and obtain a developer kit from them. Be prepared to spend a wad of dough though.
Check this out:
<http://www.nintendo.com/corp/developer.jsp> |
I'm going to tell you a secret. Once you understand it, you'll feel a lot better about the fact that Javascript obfuscation is only really useful for saving bandwidth when sending scripts over the wire.
Your source-code is not worth stealing.
I know this comes as a shock to the ego, but I can say this confidently without ever having seen a line of code you've written because outside the very few realms of development where serious magic happens, it's true of all source-code.
Say, tomorrow, someone dumped a pile of DVDs on your doorstep containing the source code for Windows Vista. What would you be able to do with it? Sure, you could compile it and give aay copies, but that's just one step more effort than copying the retail version. You could painstakingly find and remove the license-checking code, but that's something some bright kid has already done to the binaries. Replace the logo and graphics, pretend you wrote it yourself and market it as "Vicrosoft Mista"? You'll get caught.
You could spend an enormous amount of time reading the code, trying to understand it and truly "stealing the intellectual property" that Microsoft invested in developing the product. But you'd be disappointed. You'd find the code was a long series of mundane decisions, made one after the other. Some would be smarter than you could think of. Some would leave you shaking your head wondering what kind of monkeys they're hiring over there. Most would just make you shrug and say "yeah, that's how you do that."
In the process you'll learn a lot about writing operating systems, but that's not going to hurt Microsoft.
Replace "Vista" with "Leopard" and the above paragraphs don't change one bit. It's not Microsoft, it's *software*. Half the people on this site could probably develop a Stack Overflow clone, with or without looking at the source of this site. They just haven't. The source-code of Firefox and WebKit are out there for anyone to read. Now go write your own browser from scratch. See you in a few years.
Software development is an investment of time. It's utter hubris to imagine that what you're doing is so special that nobody could clone it without looking at your source, or even that it would make their job that much easier without an actionable (and easily detectable) amount of cut and paste. |
You can try [Firebug Lite][1] or use Visual Studio to debug the JavaScript.
[1]: http://getfirebug.com/lite.html |
Or [IE Developer Toolbar][1]
[1]: http://www.microsoft.com/downloads/details.aspx?FamilyId=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en |
In general, using exception handling for program flow and logic is bad practice. I personally feel that the latter option is unacceptable use of exceptions. Given the features of languages commonly used these days (such as Linq and lambdas in C# for example) there's no reason not to write your own Contains() method.
As a final thought, these days most collections *do* have a contains method already. So I think for the most part this is a non-issue. |
you can also check out the [IE Developer Toolbar][1] which isn't a debugger but will help you analyze the contents of your code.
[Visual Studio][2] will help with the debugging
[Fiddler][3] should help analyse the traffic travelling to and from your browser
[1]: http://www.microsoft.com/downloads/details.aspx?FamilyId=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en
[2]: http://weblogs.asp.net/scottgu/archive/2007/07/19/vs-2008-javascript-debugging.aspx
[3]: http://www.fiddlertool.com/fiddler/ |
And if you're building a Windows app, use the [GetFileSizeEx](http://msdn.microsoft.com/en-us/library/aa364957.aspx) API as CRT file I/O is messy, especially for determining file length, due to peculiarities in file representations on different systems ;) |
You'll probably want to set the user's shell to [the restricted shell][1]. Unset the PATH variable in the user's ~/.bashrc or ~/.bash_profile, and they won't be able to execute any commands. Later on, if you decide you want to allow the user(s) to execute a limited set of commands, like <code>less</code> or <code>tail</code> for instance, then you can copy the allowed commands to a separate directory (such as <code>/home/restricted-commands</code>) and update the PATH to point to that directory.
[1]: http://www.gnu.org/software/bash/manual/html_node/The-Restricted-Shell.html |
The general rule of thumb is to avoid using exceptions for control flow unless the circumstances that will trigger the exception are "exceptional" -- e.g., extremely rare!
If this is something that will happen normally and regularly it definitely should not be handled as an exception.
Exceptions are very, very slow due to all the overhead involved, so there can be performance reasons as well, if it's happening often enough. |
How do you redirect https to http |
|apache|ssl|https|http-redirect| |
that is, the opposite of what (seemingly) everyone teaches.
I have a server on https for which I paid an SSL cert for and a mirror for which I haven't and keep around for just for emergencies so it doesn't merit getting a cert for.
On my client's desktops I have SOME shortcuts which point to http://production_server and https://production_server (both work), however; I know that if my prod. server goes down, then DNS forwarding kicks in and those clients which have https on their shortcut will be staring at https://mirror_server (Which doesnt work) and a big fat IE7 red screen of uneasyness for my company.
Unfortunately, I can't just switch this around at the client level. These users are very computer illiterate: and are very likely to freak out from seeing https "insecurity" errors (specially the way FFX3 and IE7 handle it nowadays: FULL STOP, kinda thankfully, but not helping me here LOL).
It's [very][1] [easy][2] [to find][3] [apache solutions][4] for [http->https redirection][5], but for the life of me I can't do the opposite.
Ideas?
Cheers,
/mp
[1]: http://www.cyberciti.biz/tips/howto-apache-force-https-secure-connections.html
[2]: http://bytes.com/forum/thread54801.html
[3]: http://support.jodohost.com/showthread.php?t=6678
[4]: http://wikis.sun.com/display/About/2008/04/30/HTTP-HTTPS+Redirection+Enabled
[5]: http://www.google.com/search?q=https+redirection&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a |
I used Prototype for about six months before I decided to learn jQuery. To me, it was like a night and day difference. For example, in Prototype you will loop over a set of elements checking if one exists and then setting something in it, in jQuery you just say $('div.class').find('[name=thing]') or whatever and set it.
It's so much easier to use and feels a lot more powerful. The plugin support is also great. For almost any common js pattern, there's a plugin that does what you want. With prototype, you'll be googling for blogs that have the snippet of code you need. |
Here are some good up-to-date listings of the most-installed fonts for PC, Mac, and Linux:
[Sans serif font sampler and survey results][1]
[Serif font sampler and survey results][2]
Hope this helps your decision!
[1]: http://www.codestyle.org/css/font-family/sampler-SansSerif.shtml
[2]: http://www.codestyle.org/css/font-family/sampler-Serif.shtml |
[Bresenham's line drawing algorithm][1] got me interested in realtime graphics rendering. This can be used to render filled polygons, like triangles, for things like 3D model rendering.
[1]: http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm |
Javascript Best Practices |
|javascript|best|practices|unit-testing| |
What are some good resources to learn best practices for Javascript? I'm mainly concerned about when something should be an object vs. when it should just be tracked in the DOM. Also I would like to better learn how to organize my code so it's easy to unit test. |
|javascript|unit-testing| |
|javascript|unit-testing| |
@toolkit:
Well, not exactly. Since I can access the data source over JNDI, it is actually visible and thus usable.
Or am I getting something totally wrong?
@Brabster:
I think you're on the right track. Isn't there a way to make the connection serializable? Maybe it's just a configuration issue... |
> So is there some sort of algorithm
> that can give a percentage for how
> similar an entry is to another?
Algorithms as Soundex and Edit distances (as suggested in a previous post) can solve some of your problems. However, if you are serious about cleaning your data, this will not be enough. As others have stated "Bill" does not sound anything like "William".
The best solution I have found is to use a reduction algorithm and table to reduce the names to it's root name.
To your regular Address table, add Root-versions of the names, e.g
Person (Firstname, RootFirstName, Surname, Rootsurname....)
Now, create a mapping table.
FirstNameMappings (Primary KEY Firstname, Rootname)
Populate your Mapping table by:
Insert IGNORE (select Firstname, "UNDEFINED" from Person) into FirstNameMappings
This will add all firstnames that you have in your person table together with the RootName of "UNDEFINED"
Now, sadly, you will have to go through all the unique first names and map them to a RootName. For example "Bill", "Billl" and "Will" should all be translated to "William"
This is very time consuming, but if data quality really is important for you I think it's one of the best ways.
Now use the newly created mapping table to update the "Rootfirstname" field in your Person table. Repeat for surname and address. Once this is done you should be able to detect duplicates without suffering from spelling errors. |
AFAIK, there is no 'Integer' datatype in C99. There are a few variations on the 'int' datatype (i.e. signed and unsigned), but that's about it.
It is possible that either you were mistaken with what you read, or Joel was mistaken with what he wrote.
For the sake of interest, in object oriented languages such as Java, the 'int' type is a primitive, whereas the 'Integer' type is an object. Reasons for choosing one over the other are highly situational. |
AFAIK, there is no 'Integer' datatype in C99. There are a few variations on the 'int' datatype (i.e. signed and unsigned), but that's about it.
It is possible that either you were mistaken with what you read, or Joel was mistaken with what he wrote.
For the sake of interest, in object oriented languages such as Java and C#, the 'int' type is a primitive (and lives on the stack), whereas the 'Integer' type is an object (and lives on the heap). |
In object oriented languages such as Java and C#, the 'int' type is a primitive , whereas the 'Integer' type is an object.
The differences between objects and primitives are somewhat beyond the scope of this question, but to summarize:
**Objects** provide facilities for inheritance, reference passing and are allocated from the heap. Conversely, **primitives** are passed by value and are allocated from the stack, because primitives are extremely lightweight, they are typically cheaper to create and manipulate compared to objects. |
In object oriented languages such as Java and C#, the 'int' type is a primitive , whereas the 'Integer' type is an object.
The differences between objects and primitives are somewhat beyond the scope of this question, but to summarize:
**Objects** provide facilities for polymorphism, are passed by reference, and are allocated from the [heap](http://en.wikipedia.org/wiki/Dynamic_memory_allocation). Conversely, **primitives** are passed by value and are allocated from the [stack](http://en.wikipedia.org/wiki/Stack-based_memory_allocation). |
If you have a company buying it, Toad from Quest Software has this kind of management functionality built in. It's basically a two-click operation to compare two schemas and generate a sync script from one to the other.
They have editions for most of the popular databases, including of course Sql Server. |
I work the same way Karl does, by keeping all of my SQL scripts for creating and altering tables in a text file that I keep in source control. In fact, to avoid the problem of having to have a script examine the live database to determine what ALTERs to run, I usually work like this:
- On the first version, I place everything during testing into one SQL script, and treat all tables as a CREATE. This means I end up dropping and readding tables a lot during testing, but that's not a big deal early into the project (since I'm usually hacking the data I'm using at that point anyway).
- On all subsequent versions, I do two things: I make a new text file to hold the upgrade SQL scripts, that contain just the ALTERs for that version. And I make the changes to the original, create a fresh database script as well. This way an upgrade just runs the upgrade script, but if we have to recreate the DB we don't need to run 100 scripts to get there.
- Depending on how I'm deploying the DB changes, I'll also usually put a version table in the DB that holds the version of the DB. Then, rather than make any human decisions about which scripts to run, whatever code I have running the create/upgrade scripts uses the version to determine what to run.
The one thing this will not do is help if part of what you're moving from test to production is data, but if you want to manage structure and not pay for a nice, but expensive DB management package, is really not very difficult. I've also found it's a pretty good way of keeping mental track of your DB. |
$first = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year));
$last = date('Y-m-t', mktime(0, 0, 0, $month, 1, $year));
See [date()][1] in PHP documentation.
[1]: http://ie2.php.net/date |
Override WebClientProtocol.Timeout via web.config |
|.net|configuration| |
Is it possible to override default value of [WebClientProtocol.Timeout][1] property via web.config?
[1]: http://msdn.microsoft.com/en-us/library/system.web.services.protocols.webclientprotocol.timeout.aspx |
Is it possible to override default value of [WebClientProtocol.Timeout][1] property via web.config?
<httpRuntime executionTimeout="500" /> <!-- this doesn't help -->
[1]: http://msdn.microsoft.com/en-us/library/system.web.services.protocols.webclientprotocol.timeout.aspx |
kronoz - [in that case](#41634) (overloads for both) would it matter? If you have two overloads that took the different types you would essentially be saying that either can be passed and do the same thing.
You shouldn't have two overloads that do completely different actions depending on the types passed.
While you might get some confusion in that instance it would still be entirely type safe, you'd just have someone calling the wrong method. |
I tend to agree that VS is a heavyweight. Back in the day I coded in DOS using Boxer text editor and makefiles. Boxer didn't have the heavy intellisense and refactoring features, but it did better in the text editing department, had good syntax highlighting and startup/closing were instantaneous, even on a 486. ...those were the days.
I would say it would be really nice to customize VS to remove all the overhead you're never going to use anyway, but I don't see that happening. |
The best way to do this without any compromises would be to implement your own ControllerFactory by inheriting off of IControllerFactory. The CreateController method that you will implement handles creating the controller instance to handle the request by the RouteHandler and the ControllerActionInvoker. The convention is to use the name of the controller, when creating it, therefore you will need to override this functionality. This will be where you put your custom logic for creating the controller based on the route since you will have multiple controllers with the same name, but in different folders. Then you will need to register your custom controller factory in the application startup, just like your routes.
Another area you will need to take into consideration is finding your views when creating the controller. If you plan on using the same view for all of them, then you shouldn't have to do anything different than the convention being used. If you plan on organizing your views also, then you will need to create your own ViewLocator also and assign it to the controller when creating it in your controller factory.
To get an idea of code, there are a few questions I have answered on SO that relate to this question, but this one is different to some degree, because the controller names will be the same. I included links for reference.
- [Views in separate assemblies in ASP.NET MVC][1]
- [asp.net mvc - subfolders][2]
[1]: http://stackoverflow.com/questions/19746/views-in-seperate-assemblies-in-aspnet-mvc
[2]: http://stackoverflow.com/questions/26715/aspnet-mvc-subfolders |
You should be able to do this with xquery
try
**fn:replace(string,pattern,replace)**
I am newish to xquery myself and I have found it to be a painful query language to work with, but it does work quiet well once you get over the initial learning curve.
I do still wish there was an easier way which was as efficient?
|
I've hit the same issue - I was developing a SOAP client, and the dev server has a "homegrown" certificate. I wasn't able to solve the issue even using that method, since I wasn't using NSURL, but the (poorly documented and apparently abandoned) WS methods, and decided for the time being to (internally) just use a non-SSL connection.
Having said that, however, the question that springs to mind is, if you aren't willing to use a private API in a production app, should you be allowing access to a site with a dodgy certificate?
I'll quote [Jens Alfke][1]:
> That's not just a theoretical security problem. Something
like 25% of public DNS servers have been compromised, according to
recent reports, and can direct users to phishing/malware/ad sites even
if they enter the domain name properly. The only thing protecting you
from that is SSL certificate checking.
[1]: http://www.cocoabuilder.com/archive/message/cocoa/2008/3/4/200413 |
I emailed them asking this same question a while back and here's the response I got:
Hello,
Thank you for your email. I apologize for the delay in replying to your email. Google Analytics does not currently provide an API to access the reporting data. However, we do offer export functionality for single reports in the following formats:
- PDF
- Tab separated value (TSV)
- XML
- Excel (CSV)
This feature allows you to easily import report data into your favorite spreadsheet application or to process the data otherwise.
Additionally, we're unable to provide support for custom implementations of Google Analytics. For this level of support, you can contact one of our highly qualified Google Analytics Authorized Consultants for assistance with advanced needs. These partners deliver a number of professional services such as installation support, training, and advanced filter and e-commerce configurations.
For a complete list of our worldwide partners and a more detailed description of the services they offer, please go to http://www.google.com/analytics/support_partner_provided.html
For additional questions, please visit the Analytics Help Center at http://www.google.com/support/googleanalytics/?utm_id=tf. You can also find helpful tips and information by visiting the Google Analytics Help Forum at http://groups.google.com/group/analytics-help?utm_id=tr.
Sincerely,
[snip]
Analytics Support
*************************
For the latest updates as well as some helpful tips on Google Analytics, check out the Google Analytics blog at http://analytics.blogspot.com
************************* |
OK, we needed to resolve this issue in the short term, and so we came up with the idea of a "interop", or compatibility layer.
Baiscally, all we did was added a traditional ASMX web service to the project, and called the WCF service from that using native WCF calls. We were then able to return the appropriate types back to the client applications without a significant amount of re-factoring work. I know it was a hacky solution, but it was the best option we had with such a large legacy code-base. And the added bonus is that it actually works surprisingly well. :) |
MyObj o = null;
Assembly a = Assembly.LoadFrom("my.dll");
Type t = a.GetType("type info here");
ConstructorInfo ctor = t.GetConstructor(new Type[] { typeof(string) });
if(ctor != null)
o = ctor.Invoke(new object[] { s }); |
I like to separate the build and deploy steps into two separate steps. The output of the build step should be a package that is placed in a repository or staging area. This package should be independent of the target environments.
The deploy step is responsible for configuring the target environment and installing the package.
The reasons I prefer this approach are:
- I have one package that can run in my development, test and production environments. That should cut down the arguments between QA and development.
- There may be different elements that need to be configured during deployment. Application server settings, database schemas, data loads, etc. that might not be as easy to do from the automated build script. |
See if this works for you (untested):
Type t = a.GetType("type info here");
var ctors = t.GetConstructors();
string s = "Pass me to the ctor of t";
object o = ctors[0].Invoke(s);
If the type has more than one constructor then you may have to do some fancy footwork to find the one that accepts your string parameter. |
See if this works for you (untested):
Type t = a.GetType("type info here");
var ctors = t.GetConstructors();
string s = "Pass me to the ctor of t";
MyObj o = ctors[0].Invoke(new[] { s }) as MyObj;
If the type has more than one constructor then you may have to do some fancy footwork to find the one that accepts your string parameter.
Edit: Just tested the code, and it works.
@CoinCoin: Activator.CreateInstance doesn't have that overload on the Compact Framework. |
See if this works for you (untested):
Type t = a.GetType("type info here");
var ctors = t.GetConstructors();
string s = "Pass me to the ctor of t";
MyObj o = ctors[0].Invoke(new[] { s }) as MyObj;
If the type has more than one constructor then you may have to do some fancy footwork to find the one that accepts your string parameter.
Edit: Just tested the code, and it works.
Edit2: [Chris' answer][1] shows the fancy footwork I was talking about! ;-)
[1]: http://stackoverflow.com/questions/29436/compact-framework-how-do-i-dynamically-create-type-with-no-default-constructor#29472 |
The main reason junior engineers/programmers don't take lots of time to design and perform test scripts, is because most CS certifications do not heavily require this, so other areas of engineering are covered further in college programs, such as design patters.
In my experience, the best way to get the junior professionals into the habit, is to make it part of the process explicitly. That is, when estimating the time an iteration should take, the time of design, write and/or execute the cases should be incorporated into this time estimate.
Finally, reviewing the test script design should be part of a design review, and the actual code should be reviewed in the code review. This makes the programmer liable for doing proper testing of each line of code he/she writes, and the senior engineer and peers liable to provide feedback and guidance on the code and test written. |
You can not use REPLACE on text-fields. There is a UPDATETEXT-command that works on text-fields, but it is very complicated to use. Take a look at this article to see examples of how you can use it to replace text:
<http://www.sqlteam.com/article/search-and-replace-in-a-text-column> |
Depends on your definition of easy, but you could write a SQL Update linking the backlog item(s) to the correct backlog items.
(If there is no field in the backlog item to connect it to another backlog item, you would have to extend backlog item and the views showing them yourself) |
WMI and Win32_DeviceChangeEvent - Wrong event type returned ? |
|wmi| |
and to the makers of the site - thanks. looks like a promising beta.
I am trying to register to a "Device added/ Device removed" event using WMI. When I say device - I mean something in the lines of a Disk-On-Key or any other device that has files on it which I can access...
I am registering to the event, and the event is raised, but the EventType propery is different from the one I am expecting to see.
The documentation ([MSDN][1]) states : 1- config change, 2- Device added, 3-Device removed 4- Docking. For some reason I always get a value of 1.
Any ideas ?
Here's sample code :
public class WMIReceiveEvent
{
public WMIReceiveEvent()
{
try
{
WqlEventQuery query = new WqlEventQuery(
"SELECT * FROM Win32_DeviceChangeEvent");
ManagementEventWatcher watcher = new ManagementEventWatcher(query);
Console.WriteLine("Waiting for an event...");
watcher.EventArrived +=
new EventArrivedEventHandler(
HandleEvent);
// Start listening for events
watcher.Start();
// Do something while waiting for events
System.Threading.Thread.Sleep(10000);
// Stop listening for events
watcher.Stop();
return;
}
catch(ManagementException err)
{
MessageBox.Show("An error occurred while trying to receive an event: " + err.Message);
}
}
private void HandleEvent(object sender,
EventArrivedEventArgs e)
{
Console.WriteLine(e.NewEvent.GetPropertyValue["EventType"]);
}
public static void Main()
{
WMIReceiveEvent receiveEvent = new WMIReceiveEvent();
return;
}
}
[1]: http://msdn.microsoft.com/en-us/library/aa394124(VS.85).aspx |
Some framework provides a validation support the may keep your client and server validation in sync. Take a look at this [Seam validation tutorial][1] using annotations. It's a good implementation and very easy to understand.
Anyway, if you don't wan't to rely on frameworks, I think it is easy to implement something similar.
[1]: http://weblogs.java.net/blog/bleonard/archive/2006/05/trying_out_jbos_1.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.