Andri Yadi

A geeky technopreneur, trying to do something big with his startup

March 2009 - Posts

  • Catatan Belajar Sore Ini

    March 31, 2009

    Button_FunViewController.h

    #import <UIKit/UIKit.h>

    @interface Button_FunViewController : UIViewController {
        IBOutlet UILabel *statusText;
    }

    @property (retain, nonatomic) UILabel *statusText;

    - (IBAction)buttonPressed:(id)sender;

    @end



    Button_FunViewController.m

    #import "Button_FunViewController.h"

    @implementation Button_FunViewController
    @synthesize statusText;

    -(IBAction)buttonPressed:(id)sender
    {
        NSString *title = [sender titleForState:UIControlStateNormal];
        NSString *newText = [[NSString alloc] initWithFormat:
                             @"%@ button pressed.", title];
        statusText.text = newText;
        [newText release];
    }

    -(BOOL)shouldAutorotateInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }

    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];    
    }

    - (void)dealloc {
        [statusText release];
        [super dealloc];
    }

    @end



    Ada yang tahu itu bahasa apa dan code di atas ngapain? Kalau ada, berarti sudah ada yang lebih dulu menguasai. And to whoever he/she is: "Master, I beg you to teach me!!. You Kung fu is very good."

    More post (about this) to come.


    Share this post: | | | |
    Posted Mar 31 2009, 04:46 PM by andriyadi with 5 comment(s)
    Filed under:
  • ScreenCast of IE 8 JSON Native Support

    This is very belated posting. This was a screen cast that was captured when I delivered a talk about Internet Explorer 8 for Developer on MSDN Day, Nov 29, 2008. I know it was a long time ago, just had time to convert and publish the screen cast :)

    This is my first screen cast that uses my voice as audio. Enjoy...

    The sample code used in this screencast can be downloaded at: http://dycode.com/files/folders/msdnday/entry174.aspx

    Share this post: | | | |
  • What is The Weirdest Thing You Do Using Excel?

    Another event, another presentation and demo, but still about VSTO. Yesterday, I delivered a talk about VSTO on an event entitled "Weekend with MUGI Seminar" at University of Pasundan (UNPAD), on March 15, 2009. This time, I opened my presentation with a question "What is the Weirdest Thing You Do using Microsoft Excel?". Unfortunately, no audiences answered the question. I expected somebody will raise hand and mention something wild/weird that he/she do using Excel or Office product.

    To show the audience the uncommon thing that can be done using Excel, I did a demo to simulate pendulum motion. Before I talk about the demo, let's squeeze some brains to understand how the simulation can be made.

    The illustration of pendulum motion:


    To be able to simulate the motion, all you need to have is the motion equation. More specifically, you need to know how amplitude (theta) change with time. Let's see how we can get the equation.
    Force diagram of simple gravity pendulum is


    Some mathematical derivations:
     


    Under the initial conditions θ(0) = θ0 and dθ/dt(0) = 0, the solution of differential equation is



    And the period is



    By knowing initial theta (θ0) and string/rod length (l), I can simulate the motion. Here's the screenshot:

    At the left side, we have the simulation. At the middle, there're some input fields. And at the right side, there's a chart plotting the theta against the time. As we see, the chart is sinusoidal means the motion is Simple Harmonic Motion.

    The crowd applause when the pendulum start to swing...

    The main part of code is:

                    double thetaT = theta0;
               
                do {
                    t += dt;

                    thetaT = theta * Math.Cos(t * Math.Sqrt(9.8/(stringLength/100)));

                    pendulumY = stringLength * Math.Cos(thetaT);
                    pendulumX = stringLength * Math.Sin(thetaT);

                    pendulum.Top = platformBelow +
                                   Convert.ToSingle(pendulumY);
                    pendulum.Left = referenceLeft +
                                    Convert.ToSingle(pendulumX) - (pendulum.Width / 2);

                    System.Windows.Forms.Application.DoEvents();

                } while (true);


    Where:
    • theta0: initial theta
    • thetaT: theta at a time t
    • stringLenght: String/Rod length
    • platformBelow: the position (from the top of the screen) of platform where string/rod hangs
    • referenceLeft: the position (from the left of the screen) of reference/equilibrium line
    That looping will go forever, so you need to create code to stop it.

    To get the full source code, just grab the code and presentation slide at: http://dycode.com/files/folders/mugi/entry189.aspx

    And here're some photos during the event:






    That's it. Enjoy.



    Share this post: | | | |
  • Enabling Apache and PHP on Leopard

    Gak seperti biasanya, kali ini gw akan bahas sesuatu yang tidak "berbau" Windows, .NET, and other Microsoft products. Bukan berarti gw Microsoft MVP "murtad" :) Gw tetap cinta .NET, and still write .NET code for living. Kebetulan aja gw lagi explore suatu teknologi di atas platform yang lain. Lagian, sayang banget nih MacBook Pro kalo gak dipakai buat coding on Mac :)

    Sebenarnya ini berawal dari kebutuhan training untuk implementasi produk Microsoft juga, yaitu Windows Live Services. Bos Naren ngajak gw sama-sama ngisi HOL dan training implementasi Windows Live Service on top of PHP. Karena saat menulis posting ini, gw sedang "berada" di Mac OS 10.5.6 (Leopard) dan sedang ingin meng-enable Apache dan PHP, jadilah gw bahas bagaimana meng-enable Apache dan PHP di Leopard.

    Di dalam Leopard, khususnya Leopard 10.5.6, sebenarnya sudah terinstall Apache 2.2.9 dan PHP 5.2.5. Hanya by default, keduanya tidak di-enabled.

    Berikut langkah-langkah untuk meng-enable keduanya:
    1. Buka aplikasi TextWrangler. Jika belum terinstal, download gratis dari http://www.barebones.com/products/textwrangler. Gw pakai TextWrangler 2.3. Dari menu File --> Open, dan navigate ke  Macintosh HD:private:etc:apache2:httpd.conf. Open file tersebut.
    2. Lalu editor akan menampilkan isi file httpd.conf. Jika diperhatikan, icon pencil pada toolbar masih tersilang yang berarti bahwa file tersebut sedang di-lock. Click icon tersebut, lalu ada pertanyaan apakah akan di-unlock. Click Unlock dan file siap di-edit. Ada baiknya Anda membuat backup just in case mau back to factory setting :)
    3. Scroll down ke baris 115, sampai Anda menemukan tampilan seperti ini.
    4. Uncomment baris 115 tersebut dengan cara membuat tanda pagar (#) untuk meng-enable PHP 5.
    5. Save file tersebut. Karena file ini di-own oleh "root", ketika mencoba menyimpan file akan muncul dialog untuk memasukkan password.
    6. Nah, sekarang saatnya men-start Apache Web Server. Buka System Preferences --> Sharing. Lalu centang checkbox Web Sharing (jika belum).

    7. Untuk memastikan PHP benar-benar sudah aktif, buatlah code simple yang basi' kayak gini:
      <?php phpinfo(); ?>

      Simpan code tersebut pada file dengan nama, misalnya: phpinfo.php. Simpan file tersebut di folder Macintosh HD:Library:WebServer:Documents. Lalu buka browser dan ketikkan alamat: http://localhost/phpinfo.php. Alhasil:
    Dengan langkah-langkah di atas sebenarnya kita pakai konfigurasi PHP yang default. Kalau mau enable PHP extensions, dll, perlu utak-atik php.ini. Untuk itu, perlu extra steps berikut.
    1. Buka Terminal (dari Application:Utilities), change directory (cd) ke etc, dengan mengetik: cd /etc
    2. Buat salinan file php.ini.default menjadi php.ini, dengan cara mengetik: sudo cp php.ini.default php.ini. Masukkan password root Anda
    3. Ya sudah...utak-atiklah file php.ini tersebut.
    Udah, gitu aja. Selamat coding PHP di Leopard :)

    Share this post: | | | |