Author Archive
Problem You want to automate the exporting of a chart within an Excel worksheet to a PNG image file using a VBA macro. Solution Private Sub ExportChartToFile(Worksheet as String, ChartNumber As Integer, Filename As String) Dim objChrt As ChartObject Dim myChart As Chart Dim FilePath As String Set objChrt = Sheets(“Worksheet”).ChartObjects(n) Set myChart = objChrt.Chart […]
October 11th, 2013 | Posted in Uncategorized | No Comments
Problem You have a Team Foundation Server connected worksheet in Excel 2010, and want to automate the clicking of the Refresh button on the Team ribbon. Solution Add these two procedures to your VBA macro: Private Sub RefreshTeamQueryOnWorksheet(worksheetName As String) Dim activeSheet As Worksheet Dim teamQueryRange As Range Dim refreshControl As CommandBarControl Set refreshControl = […]
October 11th, 2013 | Posted in Team Foundation Server | No Comments
Problem: You want a simple input dialog to have the user enter a text in iOS. Solution: You can use an UIAlertView: UIAlertView * inputAlert = [[UIAlertView alloc] initWithTitle:@”New Event” message:@”Enter a title for the event” delegate:self cancelButtonTitle:@”Cancel” otherButtonTitles:@”OK”, nil]; inputAlert.alertViewStyle = UIAlertViewStylePlainTextInput; [inputAlert show]; You also need to add the UIAlertViewDelegate protocol to the […]
August 27th, 2012 | Posted in iOS, Objective-C | No Comments
Problem: In iOS, updating the user interface should be done in the main thread. However, many asynchronous methods invoke the callback on an arbitrary thread. How can I make sure a particular piece of code is run in the main thread? Solution: You need to use the grand central dispatch: dispatch_async(dispatch_get_main_queue(),^{ // The code to […]
August 26th, 2012 | Posted in iOS, Objective-C, Thread Programming, Uncategorized | No Comments
Problem: To avoid using singleton models in your iPhone/iPad apps, it’s necessary to create the root view programmatically. This way you’re able to inject the model at creation time instead of in the viewDidLoad method. Solution: Here’s how to set up a navigation-based application in code in XCode 4.2 (with automatic memory management enabled). In […]
December 22nd, 2011 | Posted in iOS, Objective-C | No Comments
Problem: Copy and other command shell commands don’t work with UNC paths, i.e. \\server\dir. Solution: Use pushd <path> to temporarily assign a drive letter and map it to the path. pushd \\server\rootfolder\subfolder When done, use popd to unmap the letter.
April 23rd, 2010 | Posted in Uncategorized | No Comments
Problem: We want to extract a date and time of the format YYYY-MM-DD MM:SS from a body of text using Ruby. Solution: This is extremely easy in ruby, and other languages that features regular expressions. require “Date” text = “Some text containing a date and a time, for instance 2010-03-19 17:25.” if text =~ /(\d{4})-(\d{2})-(\d{2}) […]
March 19th, 2010 | Posted in Ruby | 1 Comment
Problem: You’re using a third party wordpress theme but have made changes to customize it for your own needs (changed a picture, added advertising, etc.). When the third party releases an upgrade to the theme you’d like to upgrade but don’t want to lose your changes. Solution: Let your version management system move your changes […]
November 13th, 2009 | Posted in SubVersion, WordPress | No Comments
Problem: We want to insert linebreak character sequences into a string in C#. Solution: The platform safe way of doing this is by using the Environment.NewLine property. msg = “An error occurred: ” + Environment.NewLine + e.Message; Composing a string with more than one line break can become really messy, so using string.Format might be a […]
September 3rd, 2009 | Posted in C#.NET | No Comments
Problem: You want to change an action’s visible property and does so in its OnUpdate event handler, but it doesn’t seem to work. Once an action is hidden it can’t seem to become visible again. Solution: By design Delphi won’t invoke OnUpdate event handlers for actions that have their Visible property set to false. Instead, […]
September 1st, 2009 | Posted in Delphi | No Comments