instruction stringlengths 0 30k ⌀ |
|---|
|.net|architecture|web-applications|scalability| |
(I'll begin by making it clear, I am not a .NET developer and am not tied to any other environment.)
Recently, I heard that the London Stock Exchange went down for an entire day. I've also heard that the software was written in .NET. Up to this point they would experience performance hits on busy days. People seem t... |
Unfortunately, there are so many other issues that could cause a project to go down as it scales, that you have a lot to wade through before you can get down to a framework to blame. And unless you can see and thoroughly analyze the source code, it would be difficult to say what the root cause was. I'd be willing to be... |
I never use "struct" in C++.
I can't ever imagine a scenario where you would use a struct when you want private members, unless you're willfully trying to be confusing.
It seems that using structs is more of a syntactic indication of how the data will be used, but I'd rather just make a class and try to make th... |
Why would .NET have any limitations on size that other platforms wouldn't have?
I cannot imagine any situation where you are going to get 'too big' for .NET.
However, you should really specify whether you are talking about a .NET winforms application or ASP.NET as well as other relevant factors. This question is just... |
Hazzah!!!!
I went back to Michael's post, did some more poking and realized that I did needed to do a double conversion, and eventually worked out this little nugget:
Convert.ToString(Convert.ToChar(Int32.Parse(EncodedString.Substring(intParseIndex, 2), System.Globalization.NumberStyles.HexNumber)));
From ther... |
Hazzah!!!!
I went back to Michael's post, did some more poking and realized that I did needed to do a double conversion, and eventually worked out this little nugget:
Convert.ToString(Convert.ToChar(Int32.Parse(EncodedString.Substring(intParseIndex, 2), System.Globalization.NumberStyles.HexNumber)));
From ... |
In the September 2008 edition of the MSDN magazine, Brian Noyes has a excellent article about the RoutedCommand/RoutedEvents!!!
Here is the link:
http://msdn.microsoft.com/en-us/magazine/cc785480.aspx |
ruby method names |
|ruby| |
For a project I am working on in ruby I am overriding the method_missing method so that I can set variables using a method call like this: `Object.variable_name= 'new value'` (similar to setting variables in an ActiveRecord object). However, after implementing this I found out that many of the variable names have peri... |
For a project I am working on in ruby I am overriding the method_missing method so that I can set variables using a method call like this, similar to setting variables in an ActiveRecord object:
`Object.variable_name= 'new value'`
However, after implementing this I found out that many of the variable names have ... |
Related to the Levenstein distance: you might wish to normalize it by dividing the result with the length of the longer string, so that you always get a number between 0 and 1 and so that you can compare the distance of pair of strings in a meaningful way (the expression L(A, B) > L(A, C) - for example - is meaningless... |
Thamir Khason presented a excellent session about WPF/XNA/Silverlight at Tech-ed... Here is his slides:
http://blogs.microsoft.co.il/blogs/tamir/archive/2008/04/14/my-teched-08-presentation-slides-download.aspx
PS. This was quite impressive to see... he had a game that ran on the xbox. On his desktop using WPF to h... |
there is builtin stuff for it
Integer('1001') # => 1001
Integer('1001 nights')
# ArgumentError: invalid value for Integer: "1001 nights"
nuff said. |
I generally agree with most of the others - There's not really a good stepping stone language.
It is, however, useful to understand what is difficult about learning C, which might help you understand what's making it difficult for you.
I'd say the things that would prove difficult in C for someone coming from PHP... |
I'm using [jquery.pngFix.js](http://jquery.andreaseberhard.de/pngFix/). I don't know if it's officially sanctioned or not, I do know that it works. I chose it because it was the plugin included with FancyBox, no other reason. |
Best way to handle user account authentication and passwords |
|security|database-design|authentication|authorization| |
What is the best way to handle user account management in a system, without having your employees who have access to a database, to have access to the accounts.
Examples:
1. Storing username/password in the database. This is a bad idea because anyone that has access to a database can see the username and passwo... |
You could store the *salt* for the hashed password in another table, of course each user would have their own salt. You could then limit access to that table. |
1. A very bad idea indeed. If the database is compromised, all accounts are compromised.
2. Good way to go. If your hash algorithm includes the username, replacing the password hash with another one will not work.
Unix stores hashes in a a text file /etc/shadow, which is accessible only to privileged users. Passw... |
I had this email back from CVSDude:
> We are currently working on a new version of our service which willeventually include CruiseControl integration.
:-/ |
How should I load Jars dynamically at runtime? |
|java|jar| |
Why is it so hard to do this in Java? If you want to have any kind of module system you need to be able to load jars dynamically. I'm told there's a way of doing it by writing your own ClassLoader, but that's a lot of work for something that should (in my mind at least) be as easy as calling a method with a jar file ... |
I prefer using the inspect method like so:
raise @foo.inspect
It more information than to_s, like the attribute values. |
I prefer using the inspect method like so:
raise @foo.inspect
It has more information than to_s, like the attribute values. |
To avoid seeing the messages, right-click on the output window and uncheck "Show exceptions" (the name may not be exactly that, I don't have VS here right now).
However, seeing them happen might be nice, if you're interested in knowing when exceptions are thrown without setting breakpoints and reconfiguring the debu... |
I found this solution a while back but it's so hackish I'm a little embarrassed to post it here. For one it uses reflection to bypass encapsulation, and it uses deprecated methods.
But... It works flawlessly.
public class ClassPathHack {
private static final Class[] parameters = new Class[] {URL.cla... |
|installation|msi|installshield|windows-installer| |
|installation|msi|windows-installer|installshield| |
Ok,
I've got a problem here with an MSI deployment that I'm working on (using Installshield)
we have a program running in the background that needs to run per-user, this needs to start automatically without user intervention.
The problem is with GPO/AD deployment the application is started in the SYSTEM context ... |
Java code to import CSV into Access |
|java| |
I posted the code below to the Sun developers forum since I thought it was erroring (the true error was before this code was even hit). One of the responses I got said it would not work and to throw it away. But it is actually working. It might not be the best code (I am new to Java) but is there something inherentl... |
|java|csv|access| |
|java|ms-access|csv| |
VS 2005/2008 Keybinding posters:
- [Visual C# 2008 Keybinding Reference
Poster][1]
- [Visual C# 2005 Keyboard
Shortcut Reference Poster][2]
- [Visual Basic 2008 Keybinding
Reference Poster][3]
- [Visual Basic
2005 Keyboard Shortcut Reference
Poster][4]
These don't cover custom... |
I find RoboCopy is a good alternative to xcopy. It supports high latency connections much better and supports resuming a copy.
### References
[Wikipedia - robocopy](http://en.wikipedia.org/wiki/Robocopy)
### Downloads
**Edit** Robocopy was introduced as a standard feature of Windows Vista and Windows Server 2... |
There are other approaches available, such as using an abstract base class, or specialized template functions.
I'll describe the base class idea.
You can define an abstract base class
class Base { virtual bool Method(int i, const string& s) = 0; };
Then write each of your cases as a subclass, such as
... |
It was not clear if you only wanted a command line tool, but Microsoft's free [SyncToy][1] program is great for maintaining a replication between a pair of volumes. It supports pushing changes in either or both directions. That is, it support several different types of replication modes.
[1]: http://en.wikipedia... |
If you can get away with not having the main content scrollable, you might be better using the [footerStickAlt][1] method to make sure your footer stays at the bottom of the screen or the bottom of the content (if the content extends beyond the bottom of the screen).
[1]: http://www.themaninblue.com/writing/pers... |
This technet [link][1] has some good info for copying large files. I used an exchange server utility mentioned in the article which shows progress and uses non buffered copy functions internally for faster transfer.
In another scenario, I used robocopy. [Robocopy GUI][2] makes it easier to get your command line opti... |
Previous answer didn't copy directories and had a few bugs. Add the proper checks (for directory existance and so on) and catches for IO Exceptions
string[] dirs = Directory.GetDirectories(path, "*.*", SearchOption.AllDirectories);
Directory.CreateDirectory(newpath);
for (in... |
Hazzah!!!!
I went back to Michael's post, did some more poking and realized that I did needed to do a double conversion, and eventually worked out this little nugget:
Convert.ToString(Convert.ToChar(Int32.Parse(EncodedString.Substring(intParseIndex, 2), System.Globalization.NumberStyles.HexNumber)));
From ... |
The Microsoft.VisualBasic.FileIO namespace (in Microsoft.VisualBasic.dll) has a TextFieldParser you can use to split on space delimeted text. It handles strings within quotes (i.e., "this is one token" thisistokentwo) well.
Note, just because the DLL says VisualBasic doesn't mean you can only use it in a VB project... |
Many big sites like [MySpace][1], Dell.com runs on asp.net. Also, check out this [MSDN article][2] which gives a good perspective from experts.
[1]: http://highscalability.com/myspace-architecture
[2]: http://msdn.microsoft.com/en-us/magazine/cc500561.aspx |
Done right, the architecture offloads most transient state onto the client which makes clustering easier, which makes it surprisingly scalable. So it's an issue of the System as a whole as opposed to ASP.NET directly at that point.
My 2 cents. |
You also might want to look into regular expressions. That might help you out. Here is a sample ripped off from MSDN...
using System;
using System.Text.RegularExpressions;
public class Test
{
public static void Main ()
{
// Define a regular expr... |
How do I in java add a stacktrace to my debugging printout |
LINQ to the resque:
var list = new List<int>();
list.AddRange(Sequence.Range(1, x));
See [Generation Operators][1] on [LINQ 101][2]
[1]: http://msdn.microsoft.com/en-us/vcsharp/aa336752.aspx#range
[2]: http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx |
LINQ to the resque:
var list = new List<int>();
list.AddRange(Enumerable.Range(1, x));
See [Generation Operators][1] on [LINQ 101][2]
[1]: http://msdn.microsoft.com/en-us/vcsharp/aa336752.aspx#range
[2]: http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx |
LINQ to the resque:
// Adding value to existing list
var list = new List<int>();
list.AddRange(Enumerable.Range(1, x));
// Creating new list
var list = Enumerable.Range(1, x).ToList();
See [Generation Operators][1] on [LINQ 101][2]
[1]: http://msdn.microsoft.com/en-us/vcsharp/aa33... |
LINQ to the rescue:
// Adding value to existing list
var list = new List<int>();
list.AddRange(Enumerable.Range(1, x));
// Creating new list
var list = Enumerable.Range(1, x).ToList();
See [Generation Operators][1] on [LINQ 101][2]
[1]: http://msdn.microsoft.com/en-us/vcsharp/aa33... |
Safe integer parsing in Ruby |
|ruby| |
I have a string, say `'123'`, and I want to convert it to `123`.
I know you can simply do `some_string.to_i`, but that converts `'lolipops'` to `0`, which is not he effect I have in mind. I want it to blow up in my face when I try to convert something invalid, with a nice and painful `Exception`. Otherwise, I can't ... |
I have a string, say `'123'`, and I want to convert it to `123`.
I know you can simply do `some_string.to_i`, but that converts `'lolipops'` to `0`, which is not he effect I have in mind. I want it to blow up in my face when I try to convert something invalid, with a nice and painful `Exception`. Otherwise, I can't ... |
someString = "asdfasd123"
number = someString.to_i
if someString != number.to_s
puts "oops, this isn't a number"
end
probably not the cleanest way to do it, but should work |
> How do I go back to Color.White?
Two ways you can do:
- Save a copy of the settings before the user changes it.
- Cache the user modified settings and save it to Properties.Settings before the application closes. |
@ozgur,
Settings.Default.Properties["property"].DefaultValue // initial value from config file
Example:
string foo = Settings.Default.Foo; // Foo = "Foo" by default
Settings.Default.Foo = "Boo";
Settings.Default.Save();
string modifiedValue = Settings.Default.Foo; // modifiedValue = "Boo... |
I've been moving from C# in my professional career to looking at Ruby and RoR in my personal life, and I've found linux to be slightly more appealing personally for development. Particularly now that I've started using git, the implementation is cleaner on linux.
Currently I'm dual booting and getting closer to run... |
I found that if I copy tabbed lines first into a text editor and then recopy them from there to vim, then the tabs are correct. |
Use stories. Even with code examples, have a backstory: here's why someone is doing this. To increase audience participation, ask for examples of X where X is something you know you can demo, then phrase the walk-through in those terms.
Or maybe you have war stories about how it was different or how it normally ta... |
I've recently started to use Mind Mapping tools for presentations and found that it goes over very well.
[http://en.wikipedia.org/wiki/Mind_map][1]
Basically, I find people just zone out the second you start to go into details with a presentation. Conveying the information with a mind map (at least in my experien... |
|java|debugging| |
What's the easiest way to print a stacktrace from a debugging printout? Often during testing you would like to know the callstack leading up to the situation provoking a debug message. |
I prefer options like "-t text" and "-i 44"; I don't like "-fname" or "--very-long-argument=some_value".
And "-?", "-h", and "/h" all produce a help screen.
Here's how my code looks:
int main (int argc, char *argv[])
{ int i;
char *Arg;
int ParamX, ParamY;
char *Te... |
Keep your "visual representation" simple and standard.
If you're on Vista hide your desktop icons and use one of the default wallpapers. Keep your Visual Studio settings (especially toolbars) as standard and "out of the box" as possible. The more customizations you show in your environment the more likely people are... |
I recommend Scott Hanselman's post (previously mentioned). I've written up a post with some tips, mostly for selfish reasons - I review it every time before I give a technical presentation:
[Tips for a Technical Presentation][1]
If you're using a console prompt, [make sure the font is readable and that your paths... |
Nope... Just write it and make it an infix operator --using the set of special characters. // will work as an infix operator, for example, but not \\\\. See the [manual][1]:
> infix-op :=
>
> or || & && <OP >OP $OP = |OP &OP ^OP :: -OP +OP *OP /OP %OP
>
> **OP
>
>
> prefix-op :=
>
> !OP ?OP... |
MapPoint 2009 Load Performance |
|c#|winforms|com|mappoint|peformance| |
I'm having some problems integrating MS MapPoint 2009 into my WinForms .Net 2.0 application in C#. I've added the ActiveX MapPoint control onto a form and have no problems getting it to display a maps and locations; my concern is the time it takes to load a map once it is created.
The tests on my development mach... |
> This is a better method, but the account can be accessed by replacing the password hash in the database with the hash of another account that you know the auth info for.
There's really no way around this. Anyone who as write access to the password file has complete control of the computer. |
The historical performance benefit of stored procs have been from the following (in no particular order):
- Pre-parsed SQL
- Pre-generated query execution plan
- Reduced network latency
- Potential cache benefits
**Pre-parsed SQL** -- similar benefits to compiled vs. interpreted code, except on a very ... |
> **NOTE** that this is a general look at stored procedures not regulated to a specific
> DBMS. Some DBMS (and even, different
> versions of the same DBMS!) may operate
> contrary to this, so you'll want to
> double-check with your target DBMS
> before assuming all of this still holds.
>
> I've been a Sybase ASE... |
The historical performance benefit of stored procs have generally been from the following (in no particular order):
- Pre-parsed SQL
- Pre-generated query execution plan
- Reduced network latency
- Potential cache benefits
**Pre-parsed SQL** -- similar benefits to compiled vs. interpreted code, except ... |
Sorry for the previous code, it still had bugs :( (fell prey to the fastest gun problem) . Here it is tested and working. The key is the SearchOption.AllDirectories, which eliminates the need for recursion.
string path = "C:\\a";
string[] dirs = Directory.GetDirectories(path, "*.*", SearchOption.AllDirec... |
Sorry for the previous code, it still had bugs :( (fell prey to the fastest gun problem) . Here it is tested and working. The key is the SearchOption.AllDirectories, which eliminates the need for explicit recursion.
string path = "C:\\a";
string[] dirs = Directory.GetDirectories(path, "*.*", SearchOption... |
It looks like this is what I was missing: http://msdn.microsoft.com/en-us/library/aa939695.aspx |
Some relevant verbiage from C++ Standard:
3.6.2 Initialization of non-local objects [basic.start.init]
1 The storage for objects with static storage duration
(_basic.stc.static_) shall be zero-initialized (_dcl.init_) before any
other initialization takes place. Objects... |
Well I think this site is on a .net framework. As well the Microsoft site(s) are built on it. So I think that if done properly then a .net site will scale. Look at some of the comments Jeff has made about this site and the issues tend to come to coding error or architecture problems. |
You should be catching the exception in a try-catch block.
e.getStackTrace();
That returns StackTraceElement[] that you can then interpret.
Also:
e.printStackTrace()
will...print the stacktrace. |
I ended up doing the following in the btnSubmitClick()
public void btnSubmitClick(object sender, EventArgs e)
{
if (this.txtMultiLine.Text.StartsWith("\r\n"))
{
this.txtMultiLine.Text = "\r\n" + this.txtMultiLine.Text;
}
}
I must be really tired or sick or som... |
How do I open a Document from Java? |
|java|processes|windows| |
I've been using the following code to open Office Documents, PDF, etc. on my windows machines using Java and it's working fine, except for some reason when a filename has embedded it within it multiple contiguous spaces like "File[SPACE][SPACE]Test.doc".
How can I make this work? I'm not averse to canning the whole... |
Better way of opening a Document from Java? |
|java|windows|processes| |
Just creating an arbitrary exception does the trick for me:
System.out.println("Oops, the bad thing happened");
new IllegalStateException().printStackTrace(); |
For .NET 2.0, I recommend the record/playback model. We like this because it separates clearly your expectations from your verifications.
using(mocks.Record())
{
Expect.Call(foo.Bar());
}
using(mocks.Playback())
{
MakeItAllHappen();
}
If you're using .NET 3.5 and C# ... |
As well as what @jjnguy said, if you don't have an exception, you can also call Thread.getStackTrace(). |
From http://docs.python.org/ref/node33.html :
>Up to Python 2.1, old-style classes were the only flavour available to the user. The concept of (old-style) class is unrelated to the concept of type: if x is an instance of an old-style class, then x.`__class__` designates the class of x, but type(x) is always <type 'i... |
How do I create a custom type in PowerShell for my scripts to use? |
|scripting|powershell| |
I would like to be able to define and use a custom type in some of my PowerShell scripts. For example, let's pretend I had a need for an object that had the following structure:
Contact
{
string First
string Last
string Phone
}
How would I go about creating this so that I ... |
For a "whole" solution, see Raymond Hettinger's [named tuple][1] recipe. It's nice for your basic example, but also covers a bunch of edge cases you might run into later as well. Your fragment above would be written as:
MyStruct = namedtuple("MyStruct", "field1, field2, field3")
[1]: http://code.activestate.c... |
For a "whole" solution, see Raymond Hettinger's [named tuple][1] recipe. It's nice for your basic example, but also covers a bunch of edge cases you might run into later as well. Your fragment above would be written as:
MyStruct = namedtuple("MyStruct", "field1 field2 field3")
This has the advantage of having... |