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. ... |
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://luc... |
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 an... |
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 rea... |
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... |
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 ... |
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 editi... |
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 se... |
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? ... |
|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 la... |
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 ... |
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... |
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 in... |
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... |
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... |
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:... |
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... |
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-b... |
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... |
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.
... |
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.... |
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... |
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 sl... |
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_ser... |
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 ... |
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.code... |
[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 state... |
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 J... |
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 J... |
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 all... |
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... |
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 pla... |
$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 ... |
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. ...... |
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 conventi... |
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 a... |
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... |
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 i... |
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... |
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 ... |
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 y... |
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 ... |
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 ... |
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 profe... |
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... |
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... |