instruction stringlengths 0 30k ⌀ |
|---|
Clearly, you'll need a cast if you're
operating on a broken DogLeg. |
I am going to be going over the following sites/articles to help find an answer.
[The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) - Joel on Software][1]
[UTF-8 And Unicode FAQ][2]
[Hanselminutes episode "Sorting out Internationalizat... |
Creating a Math library using Generics in C# |
|c#|generics|math|interface| |
Is there any feasible way of using generics to create a Math library that does not depend on the base type chosen to store data?
In other words, let's assume I want to write a Fraction class. The fraction can be represented by two ints or two doubles or whatnot. The important thing is that the basic four arithmetic ... |
|c#|generics|interface|math| |
Is there any feasible way of using generics to create a Math library that does not depend on the base type chosen to store data?
In other words, let's assume I want to write a Fraction class. The fraction can be represented by two ints or two doubles or whatnot. The important thing is that the basic four arithmetic ... |
The ultimate text editor is, of course, emacs. I found [The Craft of Text Editing, or, Emacs for the Modern World ][1] to be an excellent self-study guide for the basics of writing an editor. The examples are all in plain old C, and the text might look a bit dated (it is from 1991), but the basic ideas are still valid,... |
How to implement the Edit -> Copy menu in c#/.net |
|.net|c#|user-interface| |
How do I implement a Copy menu item in a Windows application written in .NET 2.0?
I want to let the user to mark some rows in a datagrid and then select the Copy menu item from an Edit menu in the menubar of the application and then do a Paste in for example Excel.
What makes my head spin is how to first determin... |
|c#|.net|winforms|user-interface| |
How do I implement a Copy menu item in a Windows application written in C#/.NET 2.0?
I want to let the user to mark some text in a control and then select the Copy menu item from an Edit menu in the menubar of the application and then do a Paste in for example Excel.
What makes my head spin is how to first deter... |
What about getting everyone's input? Everyone that a person is working with will have a unique insight into that person. One person might think someone is a slacker, while another person sees that they are spending a lot of time planning before they start coding, etc. |
[Unit testing][1], [Defense Programming][2] and lots of logs
**Unit testing**
Make sure you unit test as early as possible (e.g. the password should be encrypted before sending, the SSL tunnel is working, etc). This would prevent your programmers from accidentally making the program insecure.
**Defense Program... |
Check out SQL Developer: [http://sqldeveloper.solyp.com/download/index.html] |
> What about getting everyone's input? Everyone that a person is working with will have a unique insight into that person.
That would work if (1) evaluation is conducted with open doors and (2) you've worked with that person on one project or even on the same module. As the person evaluating them, I couldn't judge ... |
I would first consider not necessarily the number of lines of code, but the value of the code that the person adds as reflective of course to what they are assigned to do. Someone told to maintain code verses building a new app is very different. Also consider how the person uses new techniques to make the code relevan... |
How to create a C++ Boost undirected graph and traverse it in depth first search (DFS) order? |
|c++|boost|graphs| |
How to create a C++ Boost undirected graph and traverse it in depth first search (DFS) order? |
Just to answer this myself in keeping with Jeff's suggestion of using Stackoverflow as a place to keep technical snippets....
From the command line use:
p4 changes -m1 @<clientname>
And just replace <clientname> with the name of your client spec. This will produce output of the form:
Change 12345 on... |
TheSeeker is correct.
Jeff Richter's advice in [Clr Via C#][1] (p638-9) on locking is to create a private object specifically for the purpose of being locked.
private Object _lock = new Object();
// usage
lock( _lock )
{
// thread-safe code here..
}
This works because _lock c... |
TheSeeker is correct.
Jeff Richter's advice in [Clr Via C#][1] (p638-9) on locking is to create a private object specifically for the purpose of being locked.
private Object _lock = new Object();
// usage
lock( _lock )
{
// thread-safe code here..
}
This works because _lock c... |
Silverlight DataBinding cross thread issue |
|silverlight|data-binding| |
I have an Image control with it's source bound to a property on an object(string url to an image). After making a service call, i update the data object with a new URL. The exception is thrown after it leaves my code, after invoking the PropertyChanged event.
The data structure and the service logic are all done... |
|multithreading|silverlight|data-binding| |
I have an Image control with it's source bound to a property on an object(string url to an image). After making a service call, i update the data object with a new URL. The exception is thrown after it leaves my code, after invoking the PropertyChanged event.
The data structure and the service logic are all done i... |
I managed to do this by sacrificing some of the ease of building the controls in the first place.
You can create a Control Library project that will generate a control library DLL for you. The drawback is that you have to create the controls with code only. In my last project, this was fine. In more complicated cont... |
Quicksort in Haskell:
qsort [] = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)
Although I couldn'd write Haskell at the time, I did understand this code and with it recursion and the quicksort algorithm. It just made click and there it was... |
Print out the records. Give the hardcopy to the idiot who decided to use a varchar(50) and ask them to find the problem record.
Next time they might just see the point of choosing an appropriate data type. |
If you only need dates (no times), the Date class in ruby should handle dates before 1970. But it has only a resolution of days. I don't know if there are solutions, if you also need times before 1970
[(source)][1]
[1]: http://safari.ibmpressbooks.com/0768667208/ch07lev1sec18 |
Ruby / Rails pre-epoch dates on windows |
|ruby|ruby-on-rails|date|exceptions| |
Working with dates in ruby and rails on windows, having problems with pre-epoch dates (before 1970) throwing out of range exceptions. Tried using both Time and DateTime objects but continuing to have the same problems. |
|ruby|ruby-on-rails|date| |
MS SQL DateTime conversion failure |
|sql|datetime| |
I have a large table with 1 million+ records. Unfortunately, the person who created the table decided to put dates in a varchar(50) field.
I need to do a simple date comparison -
datediff(dd, convert(datetime, lastUpdate), getDate()) < 31
But it fails on the convert():
Conversion failed when convert... |
Do I need to copy the .compiled files to the production server? |
|asp.net|deployment|web-deployment-project| |
I'm using a deploy project to deploy my ASP.net web application.
When I build the deploy project, all the .compiled files are re-created.
Do I need to FTP them to the production web server?
If I do a small change do I need to copy all the web site again? |
I'm using a deploy project to deploy my ASP.net web application.
When I build the deploy project, all the .compiled files are re-created.
Do I need to FTP them to the production web server?
If I do a small change do I need to copy all the web site again?
**Edit: adding answer**
From my own research, the .c... |
I'm using a deploy project to deploy my ASP.net web application.
When I build the deploy project, all the .compiled files are re-created.
Do I need to FTP them to the production web server?
If I do a small change do I need to copy all the web site again?
|
There is a gradient between web sites and web applications. However, you should alway be able to say "we are building a web site" or "we are building a web application".
Web sites should be readable down to plain HTML (no CSS, no images, no JavaScript).
Web applications, of course, could just say "Sorry, Java... |
I like [SciTE](http://www.scintilla.org/SciTE.html) as a basic editor for C++/Python on Linux. It has keyboard bindings similar to VC so you do not have to reprogram your cut-and-paste fingers.
I use it together with Git for source code control and the very useful 'git grep' command for searching in your code base.
... |
From my own research, the .compiled files must be copied to the production server, but not needed to copied every time
from [Rick Strahl][1] excellent blog:
> The output from the merge utilitity
> can combine all markup and CodeBeside
> code into a single assembly, but you
> will still end up with the .compile... |
The official [NI support page][1] and [support forums][2] are hard to beat.
It really helps having a guru around for LabVIEW.
[1]: http://www.ni.com/support/
[2]: http://forums.ni.com/ni/ |
On our project we have configuration stored in files with a <hostname> prefix then our build system pulls in the appropriate configuration based on the current system's hostname. This works well for us on a relatively small team, allowing us to apply config changes to other people's files if/when we add a new configur... |
A singleton may have a constructor and destructor. Depending on your language, the constructor may be called automatically the first time your singleton is used, or never if your singleton is not used at all. A static class would have no such automatic initialization.
Once a reference to a singleton object is obtain... |
Any dynamic languages, of course -- Python, Ruby, Smalltalk, Javascript, etc.
Among statically typed languages, the only one I know of that will allow this is Java. |
Any dynamic languages, of course -- Python, Ruby, Smalltalk, Javascript, etc. |
Did you start by just copying/moving the directory with OS commands, or did you start with SVN stuff? If you just copied the files via the OS, you would still have hidden folders containing SVN information pointing to the old location. |
Can I suggest that neither of the answers from Chris AtLee and zacherates fulfill the requirements?
I think this modification to zacerates answer is better:
def find_subclasses(module, clazz):
for name in dir(module):
o = getattr(module, name)
try:
if (o != clazz) and issubclass(o, c... |
If you want to take the next step of identifying the functions and data structures to focus on for footprint reduction, the --size-sort argument to nm can show you:
$ nm --size-sort /usr/bin/fld | tail -10
000000ae T FontLoadFontx
000000b0 T CodingByRegistry
000000b1 t ShmFont
000000ec t Font... |
What I usually do is create a general function that receives the name of the field. It adds the usual "asp.net" prefix and returns the object.
var elemPrefix = 'ctl00-ContentPlaceHolder-'; //replace the dashes for underscores
var o = function(name)
{
return document.getElementById(el... |
It sounds like ColdFusion is using Apache Axis under the covers.
This doesn't apply exactly to your solution, but I've had to deal with this issue once before when consuming a .NET web service with Apache Axis/Java. The only solution I was able to find (since the owner of the web service was unwilling to change anyt... |
Invoke is the proper way to do it if you're pushing stuff at the form from another thread.
But you might consider whether the form might be better pulling data itself, perhaps from a timer, and perhaps less frequently than a background process might push individual updates. |
Ok, turns out libxml2 has a streaming API:
http://xmlsoft.org/examples/testWriter.c
It's a little old style (very C-ish) but you can write your wrapper around it. |
You can use a combination of [strtotime](http://php.net/strtotime), [mktime](http://php.net/mktime) and [date](http://php.net/date) todo the arithmetic
Here is an example which uses a combo todo some arithmetic <http://rushi.wordpress.com/2008/04/13/php-print-out-age-of-date-in-words/> I'll reproduce the code here f... |
In addition to those comments that mention the IPet/PetBase implementation, there are also cases where providing an accessor helper class can be very valuable.
The IPet/PetBase style assumes that you have multiple implementations thus increasing the value of PetBase since it simplifies implementation. However, if y... |
Interfaces should be small. Really small. If you're really breaking down your objects, then your interfaces will probably only contain a few very specific methods and properties.
Abstract classes are shortcuts. Are there things that all derivatives of PetBase share that you can code once and be done with? If yes, th... |
I believe that WPF has amazing potential as a tool to make UIs more creative and better suited to the actual data that is being displayed, BUT..............
Just the mere act of _using_ WPF isn't going to make great UIs appear out of nowhere.
A great carpenter may use the best wood working tools, but that... |
There are obviously a number of ways to approach this, so I am going to list a number of links that should provide a better foundation to build on. These are the links that I've referenced in the past when trying to get others on the bandwagon.
- [Database Projects in Visual Studio .NET][1]
- [Data Schema - How... |
Google "Ajax activity indicator" to find lots of images and image generators (the "spinning" image itself is an animated GIF).
Here is one link to get you started:
http://www.ajaxload.info/
With the image in hand, use JQuery to toggle the visibility of the image (or perhaps its parent DIV tag).
rp |
Google "Ajax activity indicator" to find lots of images and image generators (the "spinning" image itself is an animated GIF).
Here is one link to get you started:
http://www.ajaxload.info/
With the image in hand, use JQuery to toggle the visibility of the image (or perhaps its parent DIV tag). See this link fo... |
Testing HTTPS files with MAMP |
|macos|apache|ssl|https|mamp| |
I am running MAMP locally on my laptop, and I like to test as much as I can locally. Unfortunately, since I work on e-commerce stuff (PHP), I normally force ssl in most of the checkout forms and it just fails on my laptop. Is there any easy configuration that I might be missing to allow "https" to run under MAMP? Pleas... |
Here is the sql 2005 or later version: Replace ADDR_Address with your tablename.
declare @col varchar(255), @cmd varchar(max)
DECLARE getinfo cursor for
SELECT c.name FROM sys.tables t JOIN sys.columns c ON t.Object_ID = c.Object_ID
WHERE t.Name = 'ADDR_Address'
OPEN getinfo
... |
Bit reversal of an integer, ignoring integer size and endianness |
|c|bit-manipulation|integer| |
Given an integer typedef:
typedef unsigned int TYPE;
or
typedef unsigned long TYPE;
I have the following code to reverse the bits of an integer:
TYPE max_bit= (TYPE)-1;
void reverse_int_setup()
{
TYPE bits= (TYPE)max_bit;
while (bits <<= 1)
max... |
The case statement is your friend in this situation, and takes one of two forms:
The simple case:
SELECT CASE <variable> WHEN <value> THEN <returnvalue>
WHEN <othervalue> THEN <returnthis>
ELSE <returndefaultcase>
END... |
What are my options for having the RadioButtonList functionality of ASP.NET in WinForms? |
|winforms|webforms|radio-button|radiobuttonlist| |
Is this type of control only available in a 3rd-party library? Has someone implemented an open source version? |
I also highly recommend PC-Lint. If you happen to be compiling your code with Visual Studio I recommend a plug-in 'Visual Lint' from Riverblade. If you cannot compile the code in Visual Studio, you can still run PC-Lint from the command line to good effect.
Some embedded system compilers provide MISRA compliance t... |
Use the singleton pattern when you need to compute something at runtime that you would compute at compile time if you could, like lookup tables. |
Think of a singleton like a service. It's an object which provides a specific set of functionality. E.g.
ObjectFactory.getInstance().makeObject();
The object factory is an object which performs a specific service.
By contrast, a class full of static methods is a collection of actions that you might want to... |
> but I think thats what I'm asking for..or is it?
I frankly don't know what you're asking. Java apparently has the same support for return-type covariance as C#, so if whatever you're looking for is lacking in C#, it's lacking in Java also. |
My school has always had a download link for the [Lockdown browser](http://www.respondus.com/lockdown/installinfo.pl?ID=595735824), but I've never taken a course that required it. You can probably force the student to use it with a user agent check, but it could probably be spoofed with some effort.
Proctored tests ... |
The easy way to fix many SVN errors is to move the whole directory away via the OS, update to get another clean copy of it and then merge in anything you changed with some other tool, WinMerge or the like.
After that, you can do whatever you were trying to do, but do it correctly :). |
In our last evaluation, Perforce beat subversion in its support for branching and integrating changes between branches. Work was underway on Subversion to remedy this short-coming, but we haven't been back to check it out.
In Perforce, when you branch a file, Perforce "remembers" where it came from and which revisio... |
XP with SP3 has a known issue with ATI video cards where it will not rotate the desktop.
I'm thinking I might go back to SP2 to get that back. |
My experience is that sometimes the local copy gets out of sync with the repository. I usually solve this by going up the local directory tree, starting from the directory with the problem and try to do do cleanup and update with each step. |
> Basically what I'm asking is what languages support what I'm trying to do here.
Does C# let you specify different data types for the `get()` and `set()` methods? If not, I would split them into actual `Leg get_leg()` and `set_leg(DogLeg)` functions. Otherwise one of two things will happen: 1) overspecification of ... |
Modern style is to define IPet *and* PetBase.
The advantage of the interface is that other code can use it without any ties whatsoever to other executable code. Completely "clean."
But base classes are useful for simple implementations and useful utilities. So provide an abstract base class as well for folks wh... |
Modern style is to define IPet *and* PetBase.
The advantage of the interface is that other code can use it without any ties whatsoever to other executable code. Completely "clean." Also interfaces can be mixed.
But base classes are useful for simple implementations and common utilities. So provide an abstract ... |
Opening a file stored in a database in .NET |
|sql-server|vb.net| |
I'm storing a Word document in a SQL Server 2005 database in a varbinary(max) column. Is there a way to open this document from a VB.NET Windows Forms application without serialising to a file first (i.e. directly from the byte array I've read from the database)? |
C#: Create a virtual drive in Computer |
|c#|.net|virtualization|storage| |
Is there any way to create a virtual drive in "(My) Computer" and manipulate it, somewhat like JungleDisk does it?
It probably does something like:
override OnRead(object sender, Event e) {
ShowFilesFromAmazon();
}
Are there any API:s for this? Maybe to write to an XML-file or a database, ins... |
I work for an embedded software company and our code base is quite large. The code base was designed with modules that perform specific functions and maintain some objects - also some objects exist as just independent objects. The largest problem we see with our approach is distinguishing the boundaries of modules. Our... |
It looks like you have your properties setup incorrectly.
I'm guessing your basedir property is pointing at C:\dev\Projects\springapp and your properties are using value like:
<property name="property.1" value="directory" />
instead of
<property name="property.1" location="directory" />
Using the... |
I had the same problem when programming with ActionScript and having to test it on a browser. Try <a href="http://www.flex888.com/649/debugging-flex-with-thunderbolt.html">this</a>. It involves using Firefox (which I believe you do) and FireBug to receive the debug messages.
|
We do unit testing of all logic code using DUnit and use the code coverage profiler included in [AQTime][1] to check that all paths through the code are executed by the tests.
[1]: http://www.automatedqa.com/products/aqtime/index.asp |