instruction
stringlengths
0
30k
You can do this with any data type. Simply make it a double pointer: typedef struct { int myint; char* mystring; } data; data** array; But don't forget you still have to malloc the variable, and it does get a bit complex: //initialize int x,y,w,h; w = 10; //width of array h = 20; //height of array //malloc the 'y' dimension array = malloc(sizeof(data*) * h); //iterate over 'y' dimension for(y=0;y<h;y++){ //malloc the 'x' dimension array[y] = malloc(sizeof(data) * w); //iterate over the 'x' dimension for(x=0;x<w;x++){ //malloc the string in the data structure array[y][x].mystring = malloc(sizeof(char) * 50); //50 chars //initialize array[y][x].myint = 6; array[y][x].mystring = "w00t"; } } The code to deallocate the structure looks similar - don't forget to call free() on everything you malloced! (Also, in robust applications you should [check the return of malloc()][1].) [1]: http://www.google.com/search?q=check+malloc+return
You can do this with any data type. Simply make it a double pointer: typedef struct { int myint; char* mystring; } data; data** array; But don't forget you still have to malloc the variable, and it does get a bit complex: //initialize int x,y,w,h; w = 10; //width of array h = 20; //height of array //malloc the 'y' dimension array = malloc(sizeof(data*) * h); //iterate over 'y' dimension for(y=0;y<h;y++){ //malloc the 'x' dimension array[y] = malloc(sizeof(data) * w); //iterate over the 'x' dimension for(x=0;x<w;x++){ //malloc the string in the data structure array[y][x].mystring = malloc(sizeof(char) * 50); //50 chars //initialize array[y][x].myint = 6; array[y][x].mystring = "w00t"; } } The code to deallocate the structure looks similar - don't forget to call free() on everything you malloced! (Also, in robust applications you should [check the return of malloc()][1].) Now let's say you want to pass this to a function. You can still use the double pointer, because you probably want to do manipulations on the data structure, not the pointer to pointers of data structures: int whatsMyInt(data** arrayPtr, int x, int y){ return arrayPtr[y][x].myint; } Call this function with: printf("My int is %d.\n", whatsMyInt(array, 2, 4)); Output: My int is 6. [1]: http://www.google.com/search?q=check+malloc+return
I joined an Open Source project over at CodePlex, recently. They use TFS for their source control and I have to say that it's absolutely magnificent. I'm incredibly impressed with it, so far. I'm a huge fan of the IDE integration and how easy it is to branch and tag your code. Adding a solution to source control is something like two clicks, if you've already got everything configured properly. Now. Is it worth the hefty price tag? I don't think so. The benefit to working on projects at CodePlex is it lets me get the experience with TFS that I need, in the event that I have to use it somewhere later. If you want good IDE integration for your Source Control, go grab [VisualSVN][1]. It's a much, much cheaper investment to get a lot of the same features. [1]: http://www.visualsvn.com/
Sometimes you can't choose your environment or architecture, so you're stuck working within constraints like not being able to use frameworks...
You could use **mocking frameworks** to abstract out the database engine. I don't know if PHP/Python got some but for typed languages (C#, Java etc.) there are plenty of choices It also depends on how you designed those database access code, because some design are easier to unit test than other.
You could use **mocking frameworks** to abstract out the database engine. I don't know if PHP/Python got some but for typed languages (C#, Java etc.) there are plenty of choices It also depends on how you designed those database access code, because some design are easier to unit test than other like the earlier posts have mentioned.
Avoiding a framework altogether will leave you with lots of code and a bunch of tedious browser-testing. If you would consider a framework I'd suggest jQuery with the [jqDnR][1] plugin. I think it will solve your problem. [1]: http://dev.iceburg.net/jquery/jqDnR/
Avoiding a framework altogether will leave you with lots of code and a bunch of tedious browser-testing. If you would consider a framework I'd suggest jQuery with the [jqDnR][1] plugin. I think it will solve your problem or perhaps you could combine the functionality of the [jQuery draggables][2] with the [jQuery resizables][3] [1]: http://dev.iceburg.net/jquery/jqDnR/ [2]: http://docs.jquery.com/UI/Draggables [3]: http://docs.jquery.com/UI/Resizables
The book [xUnit Test Patterns](http://www.amazon.com/xUnit-Test-Patterns-Refactoring-Addison-Wesley/dp/0131495054) describes some ways to handle unit-testing code that hits a database. I agree with the other people who are saying that you don't want to do this because it's slow, but you gotta do it sometime, IMO. Mocking out the db connection to test higher-level stuff is a good idea, but check out this book for suggestions about things you can do to interact with the actual database.
Unit testing your database access is easy enough if your project has high cohesion and loose coupling throughout. This way you can test only the things that each particular class does without having to test everything at once. For example, if you unit test your user interface class the tests you write should only try to verify the logic inside the UI worked as expected, not the business logic or database action behind that function. If you want to unit test the actual database access you will actually end up with more of an integration test, because you will be dependent on the network stack and your database server, but you can verify that your SQL code does what you asked it to do. The hidden power of unit testing for me personally has been that it forces me to design my applications in a much better way than I might without them. This is because it really helped me break away from the "this function should do everything" mentality. Sorry I don't have any specific code examples for PHP/Python, but if you want to see a .NET example I have a [post][1] that describes a technique I used to do this very same testing. [1]: http://stackoverflow.com/questions/12374/has-anyone-had-any-success-in-unit-testing-sql-stored-procedures#25204
When you change an asp.net website's config file, it restarts the application to reflect the changes... When you do an IIS Reset, that restarts all applications running on that IIS instance.
IISReset stops and restarts the entire web server (including non-ASP.NET apps) Recycling an app pool will only affect applications running in that app pool. Editing the web.config in a web application only affects that web application (recycles just that app). Editing the machine.config on the machine will recycle all app pools running. IIS will monitor the /bin directory of your application. Whenever a change is detected in those dlls, it will recycle the app and re-load those new dlls. It also monitors the web.config & machine.config in the same way and performs the same action for the applicable apps.
Application Pool recycling restarts the w3wp.exe Process *for that application pool*, hence it will only affect and Web sites running in that application pool. iisreset restarts ALL w3wp.exe Processes and any other IIS Related service, i.e. the NNTP or FTP Service. I think changing web.config or /bin does not recycle the whole Application pool, but i'm not sure on that.
You find the Lat/Lon of the city, then use a distance estimation algorithm for Lat/Lon coordinates.
How can I create virtual machines as part of a build process using MSBuild and MS Virtual Server?
|msbuild|virtualization|microsoft|
What I would like to do is create a clean virtual machine image as the output of a build of an application. So a new virtual machine would be created (from a template is fine, with the OS installed, and some base software installed) --- a new web site would be created in IIS, and the web app build output copied to a location on the virtual machine hard disk, and IIS configured correctly, the VM would start up and run. I know there are MSBuild tasks to script all the administrative actions in IIS, but how do you script all the actions with Virtual machines? Specifically, creating a new virtual machine from a template, naming it uniquely, starting it, configuring it, etc...
|microsoft|msbuild|virtualization|
What I would like to do is create a clean virtual machine image as the output of a build of an application. So a new virtual machine would be created (from a template is fine, with the OS installed, and some base software installed) --- a new web site would be created in IIS, and the web app build output copied to a location on the virtual machine hard disk, and IIS configured correctly, the VM would start up and run. I know there are MSBuild tasks to script all the administrative actions in IIS, but how do you script all the actions with Virtual machines? Specifically, creating a new virtual machine from a template, naming it uniquely, starting it, configuring it, etc... Specifically I was wondering if anyone has successfully implemented any VM scripting as part of a build process.
How can I create virtual machines as part of a build process using MSBuild and MS Virtual Server and/or Hyper-V Server Virtualization?
I know that if you use a paging repeater or gridview with the linqdatasource it will automatically optimize the number of results returned, but I'm also pretty sure in the datasource wizard you can go to advanced options and limit it to SELECT TOP 3 FROM which should allow you to do what you need
Might want to check out [Drupal](http://drupal.org/). Here are the details of the [technology stack](http://drupal.org/node/176052) that it uses. I have never used it so I can't vouch for the quality etc but definitely worth a look.
Dylan, Don't use the application config file for this purpose, use a SQL DB (SQLite, MySQL, MSSQL, whatever) because you'll have to worry less about concurrency issues during reads and writes to the config file. You'll also have better flexibility in the type of data you want to store. The appSettings section is just a key/value list which you may outgrow as time passes and as the app matures. You could use custom config sections but then you're into a new problem area when it comes to the design.
I appreciate the desire to find free software. However, in this case, I would strongly recommend looking at all options, including commercial products. I tried to play with nProf (which is at version 0.1 I think) and didn't have much luck. Even so, performance profiling an application is a subtle business and is best approached using a powerful, flexible tool. Unless you are working for free, I strongly believe the time you will save using a professional product will far outweigh the cost of a license. And of course, if you are only wanting to profile a single application, each commercial package has a 15 or 30 day trial, more than enough time to pinpoint any issues in an existing application. And if you need profiling support for more than just the one-off project, you're better buying a full strength tool anyway. We use the [ANTS profiler][1] from RedGate and have been very happy with it. I have also used [.NET Memory Profiler][2] with excellent results. The cool thing about .NET Memory Profiler is that it can attach to and profile running production applications, which really saved our butts when we had a memory leak in production we couldn't reproduce in our test lab. The JetBrains folks [have a profiler as well called dotTrace][3] which I haven't tried, but I have to believe that if it comes from the JetBrains shop it is probably top notch as well. Anyway, my advice is this: try to fix your app within the free trial window of one or an aggregated combination of the three of them (minimum of 45 days free use) and if that isn't enough time, pick your favorite and spring for one of them. You won't be sorry. [1]: http://www.red-gate.com/products/ants_profiler/index.htm [2]: http://memprofiler.com/features.aspx [3]: http://www.jetbrains.com/profiler/
The DataGrid was originally in .NET 1.0. The GridView was introduced (and replaced the DataGrid) in .NET 2.0. They provide nearly identical functionality.
DataGrid was an ASP.NET 1.1 control, still supported. GridView arrived in 2.0, made certain tasks simpler added different databinding features: This link has a comparison of DataGrid and GridView features - [http://msdn.microsoft.com/en-gb/magazine/cc163933.aspx][1] [1]: http://msdn.microsoft.com/en-gb/magazine/cc163933.aspx
Drawing a custom label on a pie chart in Yahoo's Flash Library ASTRA
|flash|actionscript-3|datatipfunction|
Has anyone looked at [Yahoo's ASTRA][1]? It's fairly nifty, but I had some issues creating a custom label for a pie chart. They have an example for a line chart, which overrides an axis's series's label renderer. My solution was to override the `myPieChart.dataTipFunction`. For data that looks like: [ { category: "Groceries", cost: 50 }, { category: "Transportation", cost: 175} ] I wrote a function like this: import com.yahoo.astra.fl.charts.series.* function (obj:Object, index:int, series:ISeries):String { return obj[index].category + "\n$" + obj[index].cost; } There's ceil(2.718281828459045) problems with this: 1. I'm directly calling the category and cost properties of the data provider. The names are actually configurable when setting up the chart, I'd like to maintain that flexibility. 2. The default data tip would show the category, the cost (without a dollar sign), and the percentage it makes up in the pie chart. So here, I've lost the percentage. I just have no idea which property of what would hold that. It might be part of the series. 3. I probably only need to override the `dataItemRenderer` for the cost part of the series, but I don't know how to access it. The documentation is a little ... lacking there. Normally I would just look at the default implementation of the `dataTipFunction` but it's all inside a compiled shm that's part of the components distributed from yahoo. Can anyone help me complete this overridden function with percentage information and the flexibility mentioned in point 1? [1]: http://developer.yahoo.com/flash/
|actionscript-3|flash|datatipfunction|
|flash|actionscript-3|datatipfunction|
Has anyone looked at [Yahoo's ASTRA][1]? It's fairly nifty, but I had some issues creating a custom label for a pie chart. They have an example for a line chart, which overrides an axis's series's label renderer. My solution was to override the `myPieChart.dataTipFunction`. For data that looks like: myPieChart.dataProvider = [ { category: "Groceries", cost: 50 }, { category: "Transportation", cost: 175} ] myPieChart.dataField = "cost"; myPieChart.categoryField = "category"; I wrote a function like this: import com.yahoo.astra.fl.charts.series.* myPieChart.dataTipFunction = function (obj:Object, index:int, series:ISeries):String { return obj[index].category + "\n$" + obj[index].cost; }; There's ceil(2.718281828459045) problems with this: 1. I'm directly calling the category and cost properties of the data provider. The names are actually configurable when setting up the chart, I'd like to maintain that flexibility. 2. The default data tip would show the category, the cost (without a dollar sign), and the percentage it makes up in the pie chart. So here, I've lost the percentage. I just have no idea which property of what would hold that. It might be part of the series. 3. I probably only need to override the `dataItemRenderer` for the cost part of the series, but I don't know how to access it. The documentation is a little ... lacking there. Normally I would just look at the default implementation of the `dataTipFunction` but it's all inside a compiled shm that's part of the components distributed from yahoo. Can anyone help me complete this overridden function with percentage information and the flexibility mentioned in point 1? [1]: http://developer.yahoo.com/flash/
@Toran: What I'm testing is the programmatic mapping from data returned from the database to quote-unquote domain model. Hence I want to mock out the database connection. For the other kind of test, I'd go for all-out integration testing. @Dale: I guess you nailed it pretty well there, and I was afraid that might be the case. If you've got pointers to any articles or suchlike where someone has done the dirty job and decomposed it into more easily digestible steps, I'd appreciate it. Code samples wouldn't hurt either. I do have a clue on how to approach that problem, but before I actually dare do that, I'm going to need to get other things done, and if testing that will require tedious mocking, then that's what I'll do.
The source code seemed to be geared for an executable, you might need to rewire stuffs a bit so it would build as a DLL instead. I don't have much experience with Visual C++ but I think it shouldn't be too hard. I guess someone might have had made a library version already, you should try Google. Once you have tesseract-ocr code in a DLL file, you can then import the file into your C# project via Visual Studio and have it create wrapper classes and do all the marshaling stuffs for you. If you can't import then [DllImport][1] will let you call the functions in the DLL from C# code. [1]: http://www.codeproject.com/KB/cs/c__and_api.aspx
The source code seemed to be geared for an executable, you might need to rewire stuffs a bit so it would build as a DLL instead. I don't have much experience with Visual C++ but I think it shouldn't be too hard with some research. My guess is that someone might have had made a library version already, you should try Google. Once you have tesseract-ocr code in a DLL file, you can then import the file into your C# project via Visual Studio and have it create wrapper classes and do all the marshaling stuffs for you. If you can't import then [DllImport][1] will let you call the functions in the DLL from C# code. Then you can take a look at the original executable to find clues on what functions to call to properly OCR a tiff image. [1]: http://www.codeproject.com/KB/cs/c__and_api.aspx
[JQuery][1] would be a good way to go. And with the [Jquery UI][2] plugins (such as [draggable][3]), it's a breeze.. (there's a [demo][4] here). Not using a framework, to keep it 'pure', seems just a waste of time to me. There's good stuff, that will save you tremendous amounts of time, time better spent in making your application even better. But you can always check out the source to get some 'inspiration', and adapt it without the overhead of the stuff you won't use. It's well done and easy to read, and you often discover some cross-browser hacks you didn't even think about.. edit: oh, if you REALLY don't wan't no framework EVER, just check out their source then.. sure you can use some of it for your application. [1]:http://jquery.com/ [2]:http://ui.jquery.com/ [3]:http://docs.jquery.com/UI/Draggables [4]:http://ui.jquery.com/repository/real-world/photo-manager/
@wilhelmtell The compiler can elide the temporary. Verbatim from the other thread: The C++ compiler is allowed to eliminate stack based temporaries even if doing so changes program behavior. MSDN link for VC 8: http://msdn.microsoft.com/en-us/library/ms364057(VS.80).aspx MSN
You should probably avoid creating your own collection for that purpose. It's pretty common to want to change the type of data structure a few times during refactorings or when adding new features. With your approach, you would wind up with a separate class for BusinessObjectList, BusinessObjectDictionary, BusinessObjectTree, etc. I don't really see any value in creating this class just because the classname is more readable. Yeah, the angle bracket syntax is kind of ugly, but it's standard in C++, C# and Java, so even if you don't write code that uses it you're going to run into it all the time.
[Tim Pope](http://www.tpope.net/) has some kickass plugins. I love his [surround](http://git.tpope.net/vim-surround.git) plugin.
It's [recommended](http://blogs.msdn.com/fxcop/archive/2006/04/27/faq-why-does-donotexposegenericlists-recommend-that-i-expose-collection-lt-t-gt-instead-of-list-lt-t-gt-david-kean.aspx) that in public API's not to use List&lt;T&gt;, but to use Collection&lt;T&gt; If you are inheriting from it though, you should be fine, afaik.
I do the exact same thing as you Jonathan... just inherit from `List<T>`. You get the best of both worlds.
I do the exact same thing as you Jonathan... just inherit from `List<T>`. You get the best of both worlds. But I generally only do it when there is some value to add, like adding a `LoadAll()` method or whatever.
Writing to the Program Files folder is a really bad idea, you should assume that this location is "read only" once installed. Saving user settings in Program Files causes problems if more than two people use the computer at once (eg. Terminal Services) who's settings should be saved, do you want other users to know 'your' settings? What happens if your program writes settings to the file as user A, but user B can't edit the file? User B may have access to the directory, but not read/delete the preference file as this is owned by user A. Legacy win9x programs often write to the program files folder, Windows Vista actually does some neat trickery to let these programs work. When your program writes a file, vista actually puts it someplace else that is only accessible to that user. The same is done for registry writes to HKLM (or so I discovered after hours of debugging...) and Server 2008 does the same thing. If you're needing to save user settings the best alternative would be to save the settings to the Application Data folder (Environment Variable %APPDATA%) If the settings are system wide, then the administrative user should set these after install or on first run and they should not be able to be overwritten by limited users. So to answer your question - YES there is a way to do what you've asked. But it's a bad idea, it's insecure and will probably cause problems in the long run.
If you want to create MSI files, try the [WiX: Windows Installer XML (WiX) toolset][1]. It's an addon to Visual Studio 2005 and above, is open-source, Microsoft endorsed, developed by employees at Microsoft. You can use XML to specify and create MSI files. [1]: http://wix.sourceforge.net/
If you want to create MSI files, try [WiX: Windows Installer XML (WiX) toolset][1]. It's an addon to Visual Studio 2005 and 2008, is open-source, and Microsoft developed. You can use XML to specify and create MSI files. There is a [wealth][2] [of][3] [resources][4] available on it, and WiX 3.0 is, although in beta, very complete. [1]: http://wix.sourceforge.net/ [2]: http://robmensching.com/blog/ [3]: http://www.joyofsetup.com/ [4]: http://blogs.msdn.com/astebner/
Languages other than SQL in postgres
|postgresql|sql|trusted-vs-untrusted|
I've been using PostgreSQL a little bit lately, and one of the things that I think is cool is that you can use languages other than SQL for scripting functions and whatnot. But when is this actually useful? For example, the documentation says that the main use for PL/Perl is that it's pretty good at text manipulation. But isn't that more of something that should be programmed into the application? Secondly, is there any valid reason to use an untrusted language? It seems like making it so that any user can execute any operation would be a bad idea on a production system. PS. Bonus points if someone can make [PL/LOLCODE][1] seem useful. [1]: http://pgfoundry.org/projects/pllolcode
|sql|database|postgresql|trusted-vs-untrusted|
make sure the user that is running the cron job has the permissions needed to encrypt the file.
This is what I ended up doing There is no domain controller in this scenario, we are only a couple of users. If I were to do it all over I would consider changing our environement to use a active directory domain. - Host Server running Windows Server 2008 with 8GB RAM and quad processor - Fresh install of Windows Server 2008 32bit in a VM under Hyper-V - Installed Application Server role with IIS - Installed SQL Server 2008 Standard edition - [Created a slipstreamed image of TFS 2008 with SP1][1] and installed TFS - Installed VSTS 2008 - Installed Team System Explorer - Installed VSTS 2008 SP1 - Installed TFS Web Access Power tool It is very important to do things in order, download the installation guide and follow it to the letter. I forgot to install the Team System Explorer until after installing SP1 and ventured into all sorts of problems. Installing SP1 once more fixed that. [1]: http://www.woodwardweb.com/vsts/000444.html
This is my recipe for installing TFS 2008 SP1. There is no domain controller in this scenario, we are only a couple of users. If I was to do it again, I would consider changing our environement to use a active directory domain. - Host Server running Windows Server 2008 with 8GB RAM and quad processor - Fresh install of Windows Server 2008 32bit in a VM under Hyper-V - Install Application Server role with IIS - Install SQL Server 2008 Standard edition - Use a user account for Reporting Services and Analysis Services - [Create a slipstreamed image of TFS 2008 with SP1][1] and install TFS - Install VSTS 2008 - Install Team System Explorer - Install VSTS 2008 SP1 - Install TFS Web Access Power tool After installing everything, reports were not generated. Found [this forum post ][2] that helped resolve the problem. - Open [p://localhost:8080/Warehouse/v1.0/warehousecontroller.asmx][3] - Run the webservice (see above link for details), it will take a little while, the tfsWarehouse will be rebuilt It is very important to do things in order, download the installation guide and follow it to the letter. I forgot to install the Team System Explorer until after installing SP1 and ventured into all sorts of problems. Installing SP1 once more fixed that. [1]: http://www.woodwardweb.com/vsts/000444.html [2]: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=317697&SiteID=1 [3]: http://localhost:8080/Warehouse/v1.0/warehousecontroller.asmx
I've used this with great success: http://sqlite.phxsoftware.com/ Free with no restrictions. --Bruce
One thing nobody seems to have mentioned is how auto-properties are unfortunately not useful for immutable objects (usually immutable structs). Because for that you really should do: private readonly string title; public string Title { get { return this.title; } } (where the field is initialized in the constructor via a passed parameter, and then is read only.) So this has advantages over a simple <code>get</code>/<code>private set</code> autoproperty.
1.6 comes with git gui that works pretty well on my mac.
When must I set a variable to "Nothing" in VB6?
|vb6|memory-leaks|
In one of my VB6 forms, I create several other Form objects and store them in member variables. Private m_frm1 as MyForm Private m_frm2 as MyForm // Later... Set m_frm1 = New MyForm Set m_frm2 = New MyForm I notice that I'm leaking memory whenever this (parent) form is created and destroyed. Is it necessary for me to assign these member variables to `Nothing` in `Form_Unload()`? In general, when is that required?
In one of my VB6 forms, I create several other Form objects and store them in member variables. Private m_frm1 as MyForm Private m_frm2 as MyForm // Later... Set m_frm1 = New MyForm Set m_frm2 = New MyForm I notice that I'm leaking memory whenever this (parent) form is created and destroyed. Is it necessary for me to assign these member variables to `Nothing` in `Form_Unload()`? In general, when is that required? SOLVED: This particular memory leak was fixed when I did an `Unload` on the forms in question, not when I set the form to `Nothing`. I managed to remove a few other memory leaks by explicitly setting some instances of Class Modules to `Nothing`, as well.
Is version control (ie. Subversion) applicable in document tracking?
|version-control|tracking|
I am in charge of about 100+ documents (word document, not source code) that needs revision by different people in my department. Currently all the documents are in a shared folder where they will retrieve, revise and save back into the folder. What I am doing now is looking up the "date modified" in the shared folder, opened up recent modified documents and use the "Track Change" function in MS Word to apply the changes. I find this a bit tedious. So will it be better and easier if I commit this in a version control database?
I am in charge of about 100+ documents (word document, not source code) that needs revision by different people in my department. Currently all the documents are in a shared folder where they will retrieve, revise and save back into the folder. What I am doing now is looking up the "date modified" in the shared folder, opened up recent modified documents and use the "Track Change" function in MS Word to apply the changes. I find this a bit tedious. So will it be better and easier if I commit this in a version control database? Basically I want to keep different version of a file. <hr> What have I learn from answers: - Use Time Machine to save different version (or Shadow copy in Vista) - There is a difference between text and binary documents when you use version control app. (I didn't know that) - Diff won't work on binary files
Woo, another Debian nut! I think you need to be a bit more specific here, Forum != CMS. Is this for internal company or external customer use? What language(s) do you know/prefer? There's no point in recommending a Perl or PHP framework if your language of choice is Ruby. Do you need to plan for scalability? What's wrong with Joomla or Drupal? I would argue that they can be successfully used on small sites. Maybe a framework isn't what you're looking for, maybe you just need a library or two (eg. [PEAR](http://pear.php.net/)?). If you need something smaller, maybe writing your own backend library that you can reuse for future projects would be a better solution. For a one-size-fits-all framework have a look at [Turbogears](http://www.turbogears.org). ("it's a big hammer, that makes every problem look like a nail")
The appSettings isn't really meant for what you are trying to do. When your .NET application starts, it reads in the app.config file, and caches its contents in memory. For that reason, after you write to the app.config file, you'll have to somehow force the runtime to re-parse the app.config file so it can cache the settings again. This is unnecessary The **best approach** would be to use a database to store your configuration settings. Barring the use of a database, you could easily setup an external XML configuration file. When your application starts, you could cache its contents in a NameValueCollection object or HashTable object. As you change/add settings, you would do it to that cached copy. When your application shuts down, or at an appropriate time interval, you can write the cache contents back out to file.
The Difference Between a DataGrid and a GridView in ASP.NET?
|asp.net|
I've been doing ASP.NET development for a little while now, and I've used both the GridView and the DataGrid controls before for various things, but I never could find a really good reason to use one or the other. I'd like to know: What is the difference between these 2 ASP.NET controls? What are the advantages or disadvantages of both? Is one any faster? Newer? Easier to maintain? The intellisense summary for the controls doesn't seem to describe any difference between the two. They both can view, edit, and sort data and automatically generate columns at runtime.
I've been doing ASP.NET development for a little while now, and I've used both the GridView and the DataGrid controls before for various things, but I never could find a really good reason to use one or the other. I'd like to know: What is the difference between these 2 ASP.NET controls? What are the advantages or disadvantages of both? Is one any faster? Newer? Easier to maintain? The intellisense summary for the controls doesn't seem to describe any difference between the two. They both can view, edit, and sort data and automatically generate columns at runtime. **Edit:** Visual Studio 2008 no longer lists DataGrid as an available control in the toolbox. It is still available (for legacy support I assume) if you type it in by hand though.
I don't know if this would work because I'm pretty sure that the keys aren't stored in the order they are added, but you could cast the KeysCollection to a List<KeyCollection> and then get the last key in the list... but it would be worth having a look. The only other thing I can think of is to store the keys in a lookup list and add the keys to the list before you add them to the dictionary... it's not pretty tho.
Has anyone looked at [Yahoo's ASTRA][1]? It's fairly nifty, but I had some issues creating a custom label for a pie chart. They have an example for a line chart, which overrides an axis's series's label renderer. My solution was to override the `myPieChart.dataTipFunction`. For data that looks like: myPieChart.dataProvider = [ { category: "Groceries", cost: 50 }, { category: "Transportation", cost: 175} ] myPieChart.dataField = "cost"; myPieChart.categoryField = "category"; I wrote a function like this: import com.yahoo.astra.fl.charts.series.* myPieChart.dataTipFunction = function (obj:Object, index:int, series:ISeries):String { return obj.category + "\n$" + obj.cost; }; There's ceil(2.718281828459045) problems with this: 1. I'm directly calling the category and cost properties of the data provider. The names are actually configurable when setting up the chart, I'd like to maintain that flexibility. 2. The default data tip would show the category, the cost (without a dollar sign), and the percentage it makes up in the pie chart. So here, I've lost the percentage. I just have no idea which property of what would hold that. It might be part of the series. 3. I probably only need to override the `dataItemRenderer` for the cost part of the series, but I don't know how to access it. The documentation is a little ... lacking there. Normally I would just look at the default implementation of the `dataTipFunction` but it's all inside a compiled shm that's part of the components distributed from yahoo. Can anyone help me complete this overridden function with percentage information and the flexibility mentioned in point 1? [1]: http://developer.yahoo.com/flash/
I'm not positive but I believe it's QT.
I don't know the specific solution, but HtmlForm.set_Action() is a function the compiler creates that acts as the setter for a property called Action. When you do: public String Action { set { DoStuff(); } } The **set** code actually becomes a function called **set_Action**. I know it's not the best answer, but I hope it helps you find the source of your problems!
Google Talk's Graphics Toolkit ?
|toolkits|
What graphics toolkit is used for the Window's Google Talk application?
|windows|gui|toolkits|
Some really good re-usable code is in [Ayende][1] Rahien's [Rhino Tools][2]. Take a peek at not only how he implements various common code, but how it is organized. [1]: http://www.ayende.com/about-me.aspx [2]: http://sourceforge.net/projects/rhino-tools/
What exactly are you having problems with? I assume you've been able to hook the pins of the encoder to your PIC as per the technical specifications linked on the Farnell page you gave, so is the problem with reading the data? Do you not get any data from the encoder? Do you not know how to interpret the data you're getting back?
[http://blogs.msdn.com/sharepoint/archive/2007/07/25/scaling-large-lists.aspx][1] [1]: http://http://blogs.msdn.com/sharepoint/archive/2007/07/25/scaling-large-lists.aspx
A good place to start would be this tutorial: <http://www.c-sharpcorner.com/UploadFile/mgold/AddIns11292005015631AM/AddIns.aspx>
I develop on Linux also, which is one reason I came up with the solution I have. I was wondering how the SourceGear options work in this respect? I have used Vault before, which in my experience wasn't too bad, but I know it is mostly Windows based. I think I read at one point that they have a client that can work on Linux, but I have never used it. I just want to open the conversation up a little more, so people who come to this question can hopefully find the best answer for them, based on their wants.
I develop on Linux also, which is one reason I came up with the solution I have. I was wondering how the SourceGear options work in this respect? I have used Vault before, which in my experience wasn't too bad, but I know it is mostly Windows based. I think I read at one point that they have a client that can work on Linux, but I have never used it. I just want to open the conversation up a little more, so people who come to this question can hopefully find the best answer for them, based on their wants. If the Vault client can run on Linux and Mac and run well, then using Vault and Fortress will definitely be the accepted answer as a good low cost alternative to Team System.
DevExpress has a *free* plug-in called [**DXCore**][1] which provides some nice abstractions upon which to then build other plug-ins...you might look into that. [1]: http://www.devexpress.com/Products/Visual_Studio_Add-in/DXCore/
> **[ALassek][1]** wrote: > > &hellip;generate the table in code&hellip; I like the look of that! It seems MUCH less likely to produce a run-time exception due to a typo or field name change. [1]: http://stackoverflow.com/users/1249/alassek
Do you really want to do it in unmanaged code? DevExpress has a nice free library to develop visual studio plugins but it's managed. This is what they use to develop Refactor and coderush http://www.devexpress.com/Products/Visual_Studio_Add-in/DXCore/ It seems the underlying API is kind of messy. As far as I know this is the easiest way.
@Gorgapor: I guess I need to take questions a little less literally sometimes. :-) I figured you were locked down to requiring some sort of index. I think you'll find though that as you use jQuery more, you usually don't need to do that sort of thing.
Interesting question. For the type of temporary table you're creating, I think it's when the stored procedure is executed. Tables created with the # prefix are accessible to the SQL Server session they're created in. Once the session ends, they're dropped. This url: http://www.sql-server-performance.com/tips/query_execution_plan_analysis_p1.aspx seems to indicate that temp tables aren't created when query execution plans are created.
It sounds to me like you need to begin implementing what is known as "separation of concerns" across your application generally. The examples folks give about templating, in response to your specific complaint about page editors breaking your code, are important, but represent just one example of this tactic. As your program gets larger and more complex it becomes harder to modify and debug--even if your designer is not breaking your code. Probably the most common separation is a three way split between data, logic and presentation as described in the design pattern Model-View-Controller (MVC). You do not need a full blown [MVC][1] framework in place to implement the same basic principles. The idea is simply to encapsulate code that deals with your data (model) in one place, the code that presents this data to the user (view) in another. You tie that code together with code that is only concerned with presenting the right data to the right user at a the right time (controller). From your description, it sounds like you have right now is a [Transaction Script][2] pattern, where you have a php file "dothis.php" that is loaded in the browser, and all the function definitions and HTML for the display are together. You already have functions, so you are already beginning to encapsulate pieces of logic. The way I would approach this would be, in keeping with the other answers here about templating, is to remove all of the HTML into another file only referencing simple PHP variables and maybe some loops (but as little conditional switching as you can). That will make the template easier to read and harder to break. When your page editor wants to modify the layout, give them THAT file. You then separate all of your data access functions to another file, ideally creating a class (or several classes, depending on how complex your data is and how frequently you need to reuse it). At this point your "dothis.php" has been stripped down to maybe some configuration code (which you can separate out to an include, and some authentication code (which you can separate out to its own class), and is only calling the data access functions, and calling the included template file. Your controller itself is therefore greatly simplified and easier to manage. [1]: http://en.wikipedia.org/wiki/Model-view-controller [2]: http://www.martinfowler.com/eaaCatalog/transactionScript.html
If you want to create MSI files, try [WiX: Windows Installer XML (WiX) toolset][1]. It's an addon to Visual Studio 2005 and 2008, is open-source, and Microsoft developed. You can use XML to specify and create MSI files. There is a [wealth][2] [of][3] [resources][4] available on it, and WiX 3.0 is, although in beta, is very complete. Also, note that you don't have to start from scratch, you can decompile an existing MSI using the WiX 'Dark' utility, modify the XML in any way you like, and then recompile it into an MSI. [1]: http://wix.sourceforge.net/ [2]: http://robmensching.com/blog/ [3]: http://www.joyofsetup.com/ [4]: http://blogs.msdn.com/astebner/
How about the about the [FlagsAttribute][1] on an enumeration. It allows you to perform bitwise operations... took me forever to find out how to do bitwise operations in .NET nicely. [1]: http://msdn.microsoft.com/en-us/library/system.flagsattribute.aspx
How to use BITS to download from a UNC path?
|vb.net|bit|
Whats the best way to distribute files to users in remote offices, using [BITS][1] with a UNC path or BITS with HTTP? I have a VB.NET project which downloads from a HTTP path currently but there is added complexity involved (having a web server, etc). Or is there a better way to do this? Low bandwith usage is more important than speed of synching. [1]: http://en.wikipedia.org/wiki/Background_Intelligent_Transfer_Service "BITS"
A very nice grep replacement for GVim is [Ack][1]. A search plugin written in Perl that beats Vim's internal grep implementation and externally invoked greps, too. It also by default skips any CVS directories in the project directory, e.g. '.svn'. [This][2] blog shows a way to integrate Ack with vim. [1]: http://petdance.com/ack/ [2]: http://blog.ant0ine.com/2007/03/ack_and_vim_integration.html
Sure..it's pretty easy. Here's a fun app I threw together. I'm assuming you have Visual C++. Save to test.cpp and compile: cl.exe /EHsc test.cpp To test with your OCX you'll need to either #import the typelib and use it's CLSID (or just hard-code the CLSID) in the CoCreateInstance call. Using #import will also help define any custom interfaces you might need. <pre> #include "windows.h" #include "shobjidl.h" #include "atlbase.h" // // compile with: cl /EHsc test.cpp // // A fun little program to demonstrate creating an OCX. // (CLSID_TaskbarList in this case) // BOOL CALLBACK RemoveFromTaskbarProc( HWND hwnd, LPARAM lParam ) { ITaskbarList* ptbl = (ITaskbarList*)lParam; ptbl->DeleteTab(hwnd); return TRUE; } void HideTaskWindows(ITaskbarList* ptbl) { EnumWindows( RemoveFromTaskbarProc, (LPARAM) ptbl); } // ============ BOOL CALLBACK AddToTaskbarProc( HWND hwnd, LPARAM lParam ) { ITaskbarList* ptbl = (ITaskbarList*)lParam; ptbl->AddTab(hwnd); return TRUE;// continue enumerating } void ShowTaskWindows(ITaskbarList* ptbl) { if (!EnumWindows( AddToTaskbarProc, (LPARAM) ptbl)) throw "Unable to enum windows in ShowTaskWindows"; } // ============ int main(int, char**) { CoInitialize(0); try { CComPtr&lt;IUnknown&gt; pUnk; if (FAILED(CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER, IID_IUnknown, (void**) &pUnk))) throw "Unabled to create CLSID_TaskbarList"; // Do something with the object... CComQIPtr&lt;ITaskbarList&gt; ptbl = pUnk; if (ptbl) ptbl->HrInit(); HideTaskWindows(ptbl); MessageBox( GetDesktopWindow(), _T("Check out the task bar!"), _T("StackOverflow FTW"), MB_OK); ShowTaskWindows(ptbl); } catch( TCHAR * msg ) { MessageBox( GetDesktopWindow(), msg, _T("Error"), MB_OK); } CoUninitialize(); return 0; } </pre>
You could always do this: string[] temp = new string[mydict.count]; mydict.Keys.CopyTo(temp, 0) int LastCount = mydict[temp[mydict.count - 1]] But I wouldn't recommend it. There's no guarantee that the last inserted key will be at the end of the array. The ordering for Keys [on MSDN][1] is unspecified, and subject to change. In my very brief test, it does seem to be in order of insertion, but you'd be better off building in proper bookkeeping like a stack--as you suggest (though I don't see the need of a struct based on your other statement)--or single variable cache if you just need to know the latest key. [1]: http://msdn.microsoft.com/en-us/library/yt2fy5zk.aspx
You could always do this: string[] temp = new string[mydict.count]; mydict.Keys.CopyTo(temp, 0) int LastCount = mydict[temp[mydict.count - 1]] But I wouldn't recommend it. There's no guarantee that the last inserted key will be at the end of the array. The ordering for Keys [on MSDN][1] is unspecified, and subject to change. In my very brief test, it does seem to be in order of insertion, but you'd be better off building in proper bookkeeping like a stack--as you suggest (though I don't see the need of a struct based on your other statements)--or single variable cache if you just need to know the latest key. [1]: http://msdn.microsoft.com/en-us/library/yt2fy5zk.aspx
I think you can do something like this, the syntax might be wrong, havent used C# in a while To get the last item Dictionary<string, int>.KeyCollection keys = mydict.keys; string lastKey = keys.Last(); or use Max instead of Last to get the max value, I dont know which one fits your code better.
Maybe you want to consider using <a href="http://www.donationcoder.com/Software/Mouser/proctamer/index.html">ProcessTamer</a> that "automatize" the process of downgrading or upgrading process priority based in your settings. I've been using it for two years. It's very simple but really effective!