Wednesday, September 29, 2010

Enable remote connection to Sql Server 2008

Recently, I had helped install a new instance of Sql server 2008 on a windows 2008 server.
The install went fine. However, I noticed that the sa account is disabled by default. This is a new feature in sql server 2008. 


You will have to login to the server as an administrator not as user with administrator rights, but as an administrator to make any changes to the sql server configuration. Once the necessary changes are made, any users with administrative rights can login and make other changes.


By default, all the ports are closed. So, you will have to go to windows firewall, add a new role to open the port for 1433. Name the rule as sql server port. Once the port is enabled, remote clients can make connections to the sql server 2008.


Port 1433 is not opened by default, even if an active instance of sql server 2008 is running on the server, it has to be manually opened via the firewall.


Thats my tip for the day.

Wednesday, September 22, 2010

iPhone SDK: MoreNavigationController

For those of you, who have more than 5 tab bar items in an iPhone Tab bar controller app. You will have noticed that the SDK automatically adds a More Tab bar item and adds all the subsequent views to a table controller.  And if you click on the More Tab, you will get the options to Configure and Edit.


This is ok for the most part. However, if your views have a custom Navigation bar item at the top of the view, having a More Navigation bar at the top and your navigation bar below it can prove to be annoying and does not lead to a nice user experience.


You can customize the More Navigation controller by the following. In your app delegate file, 
add the following lines of code in the method


-(bool) application.....didFinishLaunchingWithOptions: (NSDictionary *)......
{


//this hides the more navigation bar, you will have to write your own logic to navigate back to the previous view.
tabBarController.moreNavigationController.navigationBar.hidden = YES;


[window addSubView: tabBarController.view];
[window makeKeyAndVisible];


}

iPhone SDK : viewWillAppear

iPhone View management is really interesting. For instance, if you have a tab bar controller application and you have multiple tab bar items.


iPhone on launch of the app will automatically parse & compile all the ViewDidLoad methods across all the tab bar items. 


However, based on certain user input in one tab bar item, you might want to change the content of the another tab item, iPhone by default does not allow it. Because the ViewDidLoad method fires only once and if your code to change the content is in the ViewDidLoad method, it will never get fired till the user closes and re-opens the app. With the new iPhone 4.0, all the applications remain in the background. So even if the user closes the application by pressing the home button. The view does not get refreshed at all. More about that at a later point.




You can always force the view to refresh itself by adding your code to the method
-(void)viewWillAppear:(bool) animated
{
/*write your code to refresh your content*/
}


viewWillAppear is guaranteed to fire everytime, the view appears. 


Example: In one of my apps, I had an option to change certain items in the configuration view, all of my other views in the tab bar controller would not get refreshed to read the changed items in the configuration view unless i had a button to refresh the view content. Putting my refresh code in viewWillAppear did the trick. Now all my views get refreshed in real Time.


For those of you, who want to see this in action, download my app at
http://itunes.apple.com/us/app/homebuilders/id389989024?mt=8


Have fun folks.

Friday, September 17, 2010

Ashtothram -- my first iPhone app and the most popular of all my apps

http://itunes.apple.com/us/app/108-names/id341552746?mt=8

As per Hindu mythology, it is considered auspicious to pray to a specific God on each of the week days. There are 7 days in a week, hence 7 Gods. Each of the Gods have 108 sanskrit names (ashtothram). The app displays all the 108 names for each of the Hindu Gods. The users can simply pick day of the week and read/scroll through all the 108 names.  

Transformer Calculations -- iPhone App

my iPhone app to calculate transformer values
 http://itunes.apple.com/us/app/wiki-xfmr/id387632597?mt=8

Wiki Xfmr is an app for basic calculations related to transformer. It has five options. 1) Ratio 2) Current 3) No Load Loss Conversion 4) LoadLoss Conversion 5) Efficiency Calculator 
1)Ratio Calculate ratio of the transformer for nominal voltage and for all the taps by entering the primary and secondary voltage of a transformer.Enter the number of plus side taps, minus side taps and the taps percentage. For example - primary of 12470 with +2-2 Taps at 5% apart. will have 4 taps 2 above 2470 and 2 below 12470. Tap the ratio button to calculate the ratio with standard 0.5% tolerance. 

2)Current Calculate the rated amperes, and short circuit capability of the transformer by entering primary voltage,secondary voltage,kva and percent impedance. 

3) Load Loss Convert the loadloss from one temperature To to a new temperature by entering individual winding losses and stray losses . Select the material of the winding for accuracy. 

4)Noload loss Convert noloadloss from one temperature to another using this screen. 

5) Efficiency Efficiency of the transformer can be calculated by entering kva,losses, power factor and load factor. For 50% load choose 0.5. Please send us your comments, so we can refine the application. Use the application at your own discretion. We are not responsible for any consequences related to the usage of the formulas.
An Email and clear option exist for all the screens. Users can now email the calculated results. They can also clear the results. The app will compose an email message containing the input values and the result values and prepare a email draft. More features coming soon.

DryWall calculator -- iPhone app

My iphone app for home builders.
http://itunes.apple.com/us/app/homebuilders/id389989024?mt=8

This app is intended to help Home builders to calculate values for Dry Wall, Carpet, Paint & Floor Tiles. The app allows the user to key in the different dimensions for each of the screens, calculate values, store them, associate a picture and also email them. 

The stored values can be deleted at any time. The app allows the user to configure default values for labor rates for each of the different screens. The user can also specify a tolerance value that applies to all the screens. All results will be calculated with the actual and the tolerance values. Description of the screens is below: 


COMMON FEATURE: All calculation screens have Calculate, Save, Photo, Email, Clear buttons; 
Calculate Button: Calculates the actual and the Tolerance values.; 
Save button: Saves the quote; 
Photo: Allows the user to associate a picture from your picture album with the quote.; 
Email: Allows the user to email the quote with the associated picture.; 
Clear: Clears the screen. This is also used to clear the photo selected for your quote. Ensure to tap clear after saving/emailing a quote. 

QUOTES SCREEN:  This screen lists all the saved quotes with the latest one displayed first. Tapping on a saved quote will take you to the detail. 

RESULTS: All Screens are scrollable, please scroll to the bottom to see the entire screen. Please scroll in the results area to see all the results. DRY WALL SCREEN: All units are in FEET (ft).Tap Calculate button at the top to see the results. You can either associate a picture, save it or email the quote or simply tap clear; 

PAINT SCREEN: All units are in FEET (ft). Key in the different dimensions, key in the paint coverage per Gallon in Sq Feet ; 

CARPET SCREEN: All units are in FEET (ft). 

TILES SCREEN: All units are in FEET (ft) and inches. Key in the different dimensions, You have to choose surface tile size to continue. Optionally, you may also choose border tile size. Tapping on SELECT button for the tile size displays a picker list with the different available sizes scroll through, till you see your size and tap DONE to select.

Windows CE: ceRunAppAtTime -- Wake up device

 Recently, I have been working on a mobile for windows mobile 6.5. One of the requirements of the mobile application was to wake up the device at periodic intervals and do its job.


The default behavior of a mobile device is to suspend all non core/essential jobs running on the device, if the device is in sleep/standby mode. So, this presented a challenge. My app would run, as long as the phone was active or if the power options were changed to allow the device to do its job, when it was in sleep/inactive mode.


Luckily, for all of us, Microsoft provides a nice function called "ceRunAppAtTime". This function will force the device to run a specified application at the specified time regardless of the device's status, if it was active or in sleep/standby mode. However, the function only runs the application one time and not on a scheduled timer, which is what the requirements asked for.


You can make your program call itself after it has performed its job by using the above function. Essentially, the program is first kicked off/started in phone active mode, one of the first methods to call would be ceRunAppAtTime, ensuring that the program will call itself at the specified time.


Here is some sample code to make it happen.



namespace WakeUpDevice
{
    static class Program
    {
        ///
        /// The main entry point for the application.
        ///
        ///
        [DllImport("coredll.dll", EntryPoint = "CeRunAppAtTime", SetLastError=true)]
        public static extern bool ceRunAppAtTime(string appname, ref SYSTEMTIME lpTime);

      /*this structure is required for SYSTEMTIME*/
       public struct SYSTEMTIME
        {          
            public UInt16 wYear;
            public UInt16 wMonth;
            public UInt16 wDayOfWeek;
            public UInt16 wDay;
            public UInt16 wHour;
            public UInt16 wMinute;
            public UInt16 wSecond;
            public UInt16 wMilliseconds;
        }

        [MTAThread]
        static void Main()
        {

            string FullappName = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
            
            DateTime startTime = DateTime.Now + new TimeSpan(0, 3, 0);          

            SYSTEMTIME systemStartTime = new SYSTEMTIME();    
            systemStartTime.wDay = (ushort)startTime.Day;
            systemStartTime.wDayOfWeek = (ushort)startTime.DayOfWeek;
            systemStartTime.wHour = (ushort) startTime.Hour;
            systemStartTime.wMilliseconds = (ushort)startTime.Millisecond;
            systemStartTime.wMinute = (ushort)startTime.Minute;
            systemStartTime.wMonth = (ushort)startTime.Month;
            systemStartTime.wSecond = (ushort)startTime.Second;
            systemStartTime.wYear = (ushort)startTime.Year;

            try
            {
                bool res =  ceRunAppAtTime(FullAppName);    
               MessageBox.Show(res.ToString());
             }
            catch (Exception ex)
            {
                /*log exception*/
            }

            Application.Run(new Form1());
        }
    }
}

Have fun folks, the above function saved me.
Feel free to post a comment

iPhone -- Invalid binary

I made a change to one of my existing iphone apps and tried to upload it to the app store.
Application loader did not complain and successfully uploaded the app to the store.


However, within a few minutes, the status on the app store would change to "Invalid Binary". 
I tried uploading the binary several times with the same result. No help from Apple, there was no warning message or error message as to why the App was rejected.


After several tries,  I realized that the original app was developed in XCODE 3.1 and the new update was in XCODE 3.2. Apple changed the format of "Entitlements.plist" from XCODE 3.1 to XCODE 3.2.  I deleted the Entitlements.plist, readded it the new app, Built the app and submitted it via Application loader.


Lo and behold, within a few minutes, the status of my app changed to "Waiting for review"
YA!!


So, folks thats the tip for invalid binary.


Drop me a note, if you feel this is helpful.