instruction stringlengths 0 30k ⌀ |
|---|
Unfortunately there isn't any way to do this directly in the code. If this is an issue in house, there are various code analysis solutions that could catch these sort of problems. Have you looked into FxCop? I think that this will catch these situations and in all cases where IDisposable objects might be left hanging. ... |
I suppose you could do something like this:
#!/bin/bash
result=$( osascript << END
tell app "System Events"
set a to display dialog "What shall be the result?" default answer ""
end tell
return text returned of a
END
)
# do stuff with $result |
I don't think so. *a.concat(b)* is implemented in String and I think the implementation didn't change much since early java machines. The + operation implementation depends on java version and compiler. Currently + is implemented using StringBuffer to make the operation as fast as possible. Maybe in future this will ch... |
Niyaz is correct, but it's also worth noting that the special + operator can be converted into something more efficient by the Java compiler. Java has a StringBuilder class which represents a non-thread-safe, mutable String. When performing a bunch of String concatenations, the Java compiler silently converts
... |
[RowTest]
[Row("GoodName")]
[Row("GoodName2")]
public void Should_validate_username()
{
}
[RowTest]
[Row("BadUserName")]
[Row("Bad%!Name")]
public void Should_invalidate_username()
{
}
This might make more sense for more complex types of validation r... |
All the VS 2008 wizard does is upgrade the project & solution files to be used with VS 2008 - it still targets the framework you started with. If you want to move your projects to a newer version of the framework, you'll have to edit the project settings on each. Too much of a chance of breaking changes for MSFT to d... |
A compressed folder doesn't mean that it will be a .ZIP file, only the contents of the folder are compressed and to you it will look like a normal folder |
Apart from the target framework feature, you'll need to manually add a reference to System.Core.dll to utilise some of the latest features like Linq. |
If you're willing to put a vtable in the class you're exporting, you can export a function that returns an interface and implement the class in the .dll, then put that in the .def file. You might have to do some declaration trickery, but it shouldn't be too hard.
Just like COM. :)
MSN |
How to set encoding in .getJSON JQuery |
|jquery| |
In my web app, i submit some form fields with JQuery $.getJSON() Method. I am having some problems with the encoding. The character-set of my app is charset=ISO-8859-1 but i think this fields are submitted with UTF-8.
Does anyone know, how can i set encoding in $.getJSON calls? |
|jquery|ajax|json|character-encoding| |
I think there's probably a bug somewhere in your composition of sec and usec. I can't really say what exactly without knowing the kinds of errors you're seeing. A rough guess would be that usec can never be > 999999.
Anyway. Why not store the utime and stime components as float seconds rather than trying to buil... |
I think there's probably a bug somewhere in your composition of sec and usec. I can't really say what exactly without knowing the kinds of errors you're seeing. A rough guess would be that usec can never be > 999999.
Anyway. Why not store the utime and stime components as float seconds rather than trying to buil... |
My advice is this. Try to keep the installer as simple as possible. Windows Installer is a very complicated piece of software and when things don't work right it can be hard to figure out what's going on. I'm sure we have all experienced the endless loop of Windows Installer trying to repair a file that you no longer h... |
I think you're right to worry that the wiki thing wouldn't be hands-on enough.
How about using it as an opportunity to refresh your process too, and do a mini project "Bootcamp" where you test drive the new language and IDE features along with some new development practices. Actually create a piece of software over... |
MS has [Visual Studio training kit][1]. I think the best way is to teach the basics and then start using it in projects. Let them learn the features they need as they are using it on a project.
[1]: http://www.microsoft.com/downloads/details.aspx?FamilyID=8BDAA836-0BBA-4393-94DB-6C3C4A0C98A1&displaylang=en |
I agree with John. But there was another question that was not answered.<br />
I have done this but instead of using a database we used a flat file, it did eventually cripple the server, but it wasn't until we has ~450 active users, and if we had done it with a database it probably would have fared better.<br />This ... |
I'm not at all familiar with the inner workings of the UNIX file systems, as in how the bits and bytes are stored, but really that part is interchangeable ([ext3][1], [reiserfs][2], etc).
When people say that UNIX file systems are better, they might mean to be saying, "Oh ext3 stores bits in such as way that corrupt... |
No, not quite.
Firstly, there's a slight difference in semantics. If a is null, then the latter NPEs but the former will treat the original value of a as if it were "null".
To look under the hood, write a simple class with a += b;
public class Concat {
String cat(String a, String b) {
... |
T-SQL implementation, adapted from [dbo.UrlEncode](http://www.sqljunkies.com/WebLog/peter_debetta/archive/2007/03/09/28987.aspx):
CREATE FUNCTION dbo.Slug(@string varchar(1024))
RETURNS varchar(3072)
AS
BEGIN
DECLARE @count int, @c char(1), @i int, @slug varchar(3072)
SET @string = replace(lower(ltrim... |
@Tony: No, schemas can be useful, and indeed, we use them to partition data in our database. But I'm talking about trying to scrub sensitive data before letting a consultant have a copy of the db. I want that data gone. |
If you're using the `mysqli` library, then either the `mysqli_errno()` function or `mysqli->errno()` method will return an error number (or zero if there wasn't an error) of the most recently executed statement. (The older `mysql` library has a `mysql_errno()` function that does the exact same thing.)
Figuring out t... |
There are a few issues at play here. The first is the issue of declaring a static method without defining it. This is the difference between
public interface Foo {
public static int bar();
end
and
public interface Foo {
public static int bar() {
...
}
}
Java... |
What are the major differences between ANSI C and K&R C? |
|c|ansi-c|kr-c| |
The [Wikipedia article on ANSI C][1] says:
> One of the aims of the ANSI C standardization process was to produce a superset of K&R C (the first published standard), incorporating many of the unofficial features subsequently introduced. However, the standards committee also included several new features, such as fun... |
Formview problem |
|asp.net|formview| |
I have a form view, in the edit template I have two drop downs.
Drop down 1 is explicitly set with a list of allowed values. It is also set to autopostback.
Drop down 2 is databound to an objectdatasource, this objectdatasource uses the first dropdown as one of it's parameters. (The idea is that drop down 1 limits w... |
Updated to remove the stuff about errno functions which I now realize don't apply in your situation...
One thing in MySQL to be wary of for `UPDATE` statements: `mysqli_affected_rows()` will return zero even if the `WHERE` clause matched rows, but the `SET` clause didn't actually change the data values. I only menti... |
@Quarrelsome
> If will get called when the object is moved out of scope and is tidied by the garbage collector.
This statement is misleading and how I read it incorrect: There is absolutely no guarantee when the finalizer will be called. You are absolutely correct that billpg should implement a finalizer; howeve... |
This is no different from a programmer forgetting to use _delete_ in C++, except that at least here the garbage collect will still eventually catch up with it.
And you never need to use IDisposable if the only resource you're worried about is memory. The framework will handle that on it's own. IDisposable is only ... |
This is no different from a programmer forgetting to use _delete_ in C++, except that at least here the garbage collector will still eventually catch up with it.
And you never need to use IDisposable if the only resource you're worried about is memory. The framework will handle that on it's own. IDisposable is onl... |
How to do C++ style destructors in C#? |
|c#|using|dispose|idisposable| |
I've got a C# class with a Dispose function via IDisposable. Its intended to be used inside a using block so the expensive resource it handles can be released right away.
Problem is that a bug occurred when an exception was thrown before Dispose was called, and the programmer neglected to use using or finally.
&l... |
Build a time machine and go back to 1987? Ho ho.
Ok, no more snarky comments.
> How do I figure out what the configuration settings (e.g. baud rate) should be...
Read the datasheet? Ok, ok. Seriously, last one. If you don't know the baud rate of the device you are trying to communicate with, you have two choi... |
You mention your Dad was using a website publishing tool.
If the publishing tool publishes from his computer to the server, it may be the case that his local files are clean, and that he just needs to republish to the server.
He should see if there's a different login method to his server than plain FTP, though..... |
To recurse on a solved problem: do nothing, you're done.
To recurse on an open problem: do the next step, then recurse on the rest. |
What is Inversion of Control? |
|inversion-of-control|design-patterns| |
Inversion of Control (or IoC) can be quite confusing when it is first encountered.
1. What is it?
2. What problems does it solve?
3. When is it appropriate and when not? |
From the other side, if you want to do it using C#, which will run on both Windows and Linux--with some [limitations][1] (EDIT: which may be out of date. I have no way to test it.). Just create a [SerialPort][2] object, set its baudrate, port and any other odd settings, call open on it, and write out your byte[]s. Afte... |
Calling a Function From a String With the Function's Name in Python |
I think there's probably a bug somewhere in your composition of sec and usec. I can't really say what exactly without knowing the kinds of errors you're seeing. A rough guess would be that usec can never be > 999999, so you're relying on overflow to know when to adjust sec. It could also just be a problem with your dur... |
From a security perspective, I know that it is possible to spoof a MAC, though I am not entirely sure how difficult it is or what it entails.
Otherwise, if the customers don't have easy access to the hardware or the OS, you should be fairly safe doing this... probably best to put a warning sticker on saying that mes... |
I'm not using a custom "new form", so this might not apply. I added an event receiver to my custom content type and then do my custom code in the ItemAdded or ItemAdding events. This code fires when the event is added to a list. You can use the event receiver properties to get to the parent List, Web, and Site. |
G'day,
I guess one thing that nobody seems to have asked is if you have a legal requirement to store history of changes to the doc's?
Whether you do or don't is going to have an impact on what solutions you can consider.
Also a notification mechanism for out of date copies is also a bundle of fun. If engineer ... |
G'day,
I guess one thing that nobody seems to have asked is if you have a legal requirement to store history of changes to the doc's?
Whether you do or don't is going to have an impact on what solutions you can consider.
Also a notification mechanism for out of date copies is also a bundle of fun. If engineer ... |
|c#|dispose|using|idisposable| |
I've got a C# class with a Dispose function via IDisposable. Its intended to be used inside a using block so the expensive resource it handles can be released right away.
Problem is that a bug occurred when an exception was thrown before Dispose was called, and the programmer neglected to use using or finally.
&l... |
As far as I can tell, the only reason why Chrome installs into the Application Data folder is so that non-admin users can install it.
The Chrome installer currently does not allow the user to pick where the application is to be installed. Don't do that – instead, give the user a choice between a per-user (somewhere ... |
Yes, they are. I'd personally recommend looking at [SSW's rules to better unit tests][1]. It contains some very helpful naming guidelines.
[1]: http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterUnitTests.aspx |
One I used with my kids is [CEEBot][1]. It's not python, but it teaches C / Java style programming in a fun, robot-programming kind of game. It is aimed at 10-15 year olds, but it is a really good one.
[1]: http://www.ceebot.com/ceebot/index-e.php |
~ClassName()
{
}
If will get called when the object is moved out of scope and is tidied by the garbage collector.
This is called a Finalizer. All objects with a finaliser get put on a special finalise queue by the garbage collector where the finalise method is invoked on them (so it's technically a pe... |
I refer to [A List Apart][1] articles all the time for those sorts of things. They do a lot of trial-and-error research to come up with really creative ways to handle those common CSS problems in the cleanest most portable way possible.
[1]: http://www.alistapart.com/ |
To get rid of "This field is required," you need to make it not required, by using blank=True (and possibly null=True as well, if it's not a CharField). |
Ruby "is" equivalent |
|python|ruby|identical| |
Is there a Ruby equivalent for Python's "is"? It tests whether two objects are identical (i.e. have the same memory location). |
Use `a.equal? b`
http://www.ruby-doc.org/core/classes/Object.html
> Unlike ==, the equal? method should never be overridden by subclasses: it is used to determine object identity (that is, a.equal?(b) iff a is the same object as b). |
Dot notation for property access in Objective-C **is** a message send, just as bracket notation. That is, given this:
@interface Foo : NSObject
@property BOOL bar;
@end
Foo *foo = [[Foo alloc] init];
foo.bar = YES;
[foo setBar:YES];
The last two lines will compile exactly the same.... |
First, there is no such thing as "the Unix file system".
Second, upon what premise does your argument rest? Did you hear someone say it was superior? Perhaps if you offered some source, we could critique the specific argument. |
First, there is no such thing as "the Unix file system".
Second, upon what premise does your argument rest? Did you hear someone say it was superior? Perhaps if you offered some source, we could critique the specific argument.
**Edit:** Okay, according to [http://en.wikipedia.org/wiki/Comparison_of_file_systems][... |
What makes the Unix file system more superior to the Windows file system? |
|unix|filesystems| |
I'll admit that I don't know the inner workings of the unix operating system, so I was hoping someone could shed some light on this topic.
Why is the unix file system better than the windows file system?
Would grep work just as well on windows, or is their something fundamentally different that makes it more powe... |
I'll admit that I don't know the inner workings of the unix operating system, so I was hoping someone could shed some light on this topic.
Why is the unix file system better than the windows file system?
Would grep work just as well on windows, or is their something fundamentally different that makes it more powe... |
The biggest single difference, I think, is function prototyping and the syntax for describing the types of function arguments.
|
ASP.NET gzip compression corrupting CSS |
|asp.net|compression|gzip| |
I have an ASP.NET webforms application (3.5 SP1) that I'm working on, and attempting to enable gzip fpr HTML and CSS that comes down the pipe. I'm using [this implementation][1] (and tried a few others that hook into Application_BeginRequest), and it seems to be corrupting the external CSS file that the pages use, but ... |
I would try a framework. *Zend Framework* has been cited. [Symfony][1] seems interesting. It's based on ideas from *Ruby on Rails*.
[1]: http://www.symfony-project.org/ |
I don't know if there is a way to optimize UpdatePanels, but my company has found its performance to be pretty poor. jQuery is much much faster at doing pretty much anything.
There can be a lot of lag between the time when an UpdatePanel triggers an update and when the UpdatePanel actually updates the page.
The o... |
What a good machine for iPhone development? |
|iphone|apple|macos|imac| |
I'm going to be working on some iPhone apps so I've been given a golden ticket to buy a Mac. However the golden ticket isn't worth that much, and I'm thinking iMac. Now, Macs are great, I love 'em and use 'em at home, but I know that the iMac is geared more towards the average consumer than the professional. Is an iMac... |
What's a good machine for iPhone development? |
|macos|iphone|apple|imac| |
There are some minor differences, but I think later editions of K&R are for ANSI C, so there's no real difference anymore.
"C Classic" for lack of a better terms had a slightly different way of defining functions, i.e.
int f( p, q, r )
int p, float q, double r;
{
// Code goes here ... |
~ClassName()
{
}
EDIT (bold):
If will get called when the object is moved out of scope and is tidied by the garbage collector **however this is not deterministic and is not guaranteed to happen at any particular time**.
This is called a Finalizer. All objects with a finaliser get put on a special f... |
Windows still lacks a convention for per-user installation.
* When an installer asks whether to install for the current user or all users, it really only refers to shortcut placement (Start Menu; Desktop). The actual application files still go in the system-wide `%PROGRAMFILES%`.
* Microsoft's own ClickOnce works a... |
Yes, the names are totally important, specially when you are running the tests in console or continuous integration servers. Jay Fields wrote a [post about it][1].
Moreover, put good test names with [one assertion per test][2] and your suite will give you great reports when a test fails.
Kind Regards
[1]: ... |
java String concatenation |
|java|string| |
I'm curious and wasn't sure, so i thought id ask:
assuming String a and b.
a+=b
a.concat(b)
Under the hood are they the same thing? |
I'm curious and wasn't sure, so i thought id ask:
assuming String a and b.
a+=b
a.concat(b)
Under the hood are they the same thing?
Edit:
Here is concat decompiled as reference, I'd like to be able to decompile the + operator as well to see what that does, not sure how to do that yet.
... |
What kibbee said.
For the part of your question about existing on a release build, it depends on what kind of web site you have. If you have a pre-compiled web site, then _none_ of code files (.vb, .cs, etc) need to be deployed the server. They are compiled into .dlls (assemblies) and deployed that way along wit... |
All versions of the .Net Framework from 2.0 onwards (i.e. 3.0 and 3.5) use exactly the same core framework files (i.e. the CLR, you'll notice there are no directories relating to 3.0 or 3.5 in the C:\Windows\Microsoft.Net\Framework directory) therefore you shouldn't worry too much about any performance issues.
The C... |
Avoiding repeated constants in CSS |
|css| |
Are there any useful techniques for reducing the repetition of constants in a CSS file?
(For example, a bunch of different selectors which should all apply the same colour, or the same font size)? |
Here's what I ended up with. I have never found another solution out there for this, so if you have something better, by all means, contribute.
First, the long array definition in the wsdl:types area:
<xsd:complexType name="ArrayOf_xsd_long">
<xsd:complexContent mixed="false">
<xsd:rest... |
Editing User Profile w/ Forms Authentication |
|moss|wss| |
We're using Forms Authentication in SharePoint. When the account is created, the administrator can add some information, like name and address. But the required fields are username and email address.
When a user goes to their profile page, all the fields are blank and they are unable to edit them. I have read a n... |
|sharepoint|moss|wss| |
> The original prefix was meant to be
> used to spot problems in equations,
> but has somehow devolved into making
> the code slightly easier to read since
> you don't have to go look for the
> variable declaration. With todays
> smart editors where you can simply
> hover over any variable to find the
> full ty... |