• Home
  • Genetik
  • Google
  • Links
  • About
  • Yohan Naftali

    Programming

    Event onkeyup pada Javascript

    Mar. 27, 2011

    Berikut ini adalah contoh aplikasi kode javascript menggunakan event onkeyup pada input form.

     

    <html>

    <head>

    <script type=”text/javascript”>

    function hitung()

    {

    var ttlbelanja=document.getElementById(“totalbelanja”).value;

    var tendered=document.getElementById(“uang”).value;

    var kembali=tendered-ttlbelanja;

    if(kembali<0)

    {

    kembali = “Uang Belum Cukup”;

    }
    document.getElementById(“kembali”).innerHTML=kembali;

    }


    function uangotomatis()

    {

    var ttlbelanja=document.getElementById(“totalbelanja”).value;

    document.getElementById(“uang”).value=ttlbelanja;

    document.getElementById(“kembali”).innerHTML=0;

    }

    </script>

    </head>

    <body>

    <h1>Menghitung Uang Kembali</h1>

    <form>

    Total Belanja:

    <input type=”text” id=”totalbelanja” name=”totalbelanja” onkeyup=”uangotomatis()” />

    <br />

    Uang:

    <input type=”text” id=”uang” name=”uang” onkeyup=”hitung()”/>

    <br />

    </form>

    <div style=”float:left;”>Kembali: &nbsp;</div>

    <div style=”float:left;” id=”kembali”> </div>

    <br />

    </body>

    </html>


    Share on Facebook Delicious Bookmark this on Delicious

    Code::Blocks Simple Hello World Console Applications

    Feb. 22, 2011

    Create New Project from File -> New -> Project

    Pick New Console Project then Click Go

    Click Next

    Select C then Click Next

    Fill project title and choose folder to create project in

    Choose GNU GCC Compiler and then click Finish

    Create Code in main.c files
    #include <stdio.h>
    #include <stdlib.h>

    int main()
    {
    printf(“Hello world!\n”);
    return 0;
    }

    Build -> Run (or simply press Ctrl + F10) or Press F9 to Build and Run

    Yes

    Your first C program accomplished


    Share on Facebook Delicious Bookmark this on Delicious

    Substitute TTF Font on Epson TM-U220 Receipt Printer

    Feb. 12, 2011

    I found it’s tricky in printing Epson’s receipt printer font (TM-U220) on web browser point of sale application, CSS does not allowed me to access Epson’s receipt printer font. All you need to do is setting font substitution in printing preferences.

    1. Open Control Panel to access Printers
    2. On Epson’s Receipt Printer do right click then select Printing Preferences
    3. Select Tab Printer Settings
    4. On True Type Font Substitution choose Substitute options
    5. Click Advanced Setting to configure font substitution, or simply choose substitute all
    6. Choose Machine Font that you like (e.g FontB)
    7. Test Print and do trial and error ’till you get what you want

    These steps are my best solution so far, do you have better/simple solutions to printing using machine Receipt Printer on web based Point of Sale applications? Tell me.


    Share on Facebook Delicious Bookmark this on Delicious

    How to Disable Print Dialog on Firefox Browser

    Feb. 12, 2011

    Annoying with print dialog?
    Need to disable print dialog on your controlled environment?
    Need to disable print dialog on your web based Point of Sale (POS) applications (e.g phppointofsale)?
    Need to disable print dialog on your web based ticket printing applications?

    1. Type about:config on address bar
    2. Choose to promise
    3. Right clicik and create new boolean
      “print.always_print_silent = true”
      “print.show_print_progress = false”

    Done

    Note: Make sure to set default printer to your desired printer and all parameter already configured


    Share on Facebook Delicious Bookmark this on Delicious

    Konsep Pemrograman MVC (Model View Controller)

    Feb. 02, 2011

    MVC adalah sebuah bentuk pemrograman yang memisahkan berdasarkan logika penanganan tampilan, logika pengontrolan dan logika model. MVC bertujuan supaya pada pengembangan perangkat lunak yang besar mudah untuk dilakukan maintenance (perbaikan/penambahan atau pengurangan code).

    Model adalah komponen yang berfungsi mengambil data dari database/sumber data. Fungsi yang terdapat dalam Model akan dipanggil oleh Controller.

    View adalah komponen yang berfungsi menyajikan tampilan kepada user. View menampilkan data yang diperoleh Controller.

    Controller adalah komponen yang berfungsi untuk memanggil fungsi yang ada di dalam Model dan mengirim hasilnya melalui View, Controller juga berfungsi mengambil input dari user yang selanjutnya akan diolah oleh Model.

    Model adalah komponen yang berfungsi mengambil data dari database/sumber data. Fungsi yang terdapat dalam Model akan dipanggil oleh Controller.


    Share on Facebook Delicious Bookmark this on Delicious

    Menggunakan Anchor dengan image pada CodeIgnitier

    Sep. 15, 2010

    HTML :

    <a href=”http://urltujuan.html”><img src=”/images/image.gif” style=”border: 0px”></a>

    CodeIgniter:

    Load html helper untuk menggunakan fungsi img()
    <?php $this->load->helper(‘html’);?>

    Gunakan fungsi img()
    <?php echo anchor(“http://urltujuan.html”, img(array(‘src’=>’../images/image.gif’,'style’=>’border:0px’))); ?>


    Share on Facebook Delicious Bookmark this on Delicious

    Even or Odd?

    Oct. 20, 2009

    There are many ways to determine wheter the number is odd or even. Here is two:
    1. Check with modulus operator (%)
    The modulus operator returns the remainder when dividing two numbers.
    Even numbers doesn’t have a remainder, but Odd numbers have 1.
    2. Check by bit operators

    Here is the code:
    1. With modulus operator (%)
    ———————————-
    #include
    int main() {
    int number;
    printf(“Input integer\n”);
    scanf(“%d”,&number);
    if(number % 2 == 0) {
    printf(“Even\n”);
    }
    else {
    printf(“Odd\n”);
    }
    return 0;
    }
    ———————————-

    2. Check by bit operator
    ———————————-
    #include
    int main() {
    int number;
    printf(“Input integer\n”);
    scanf(“%d”,&number);
    if(number & 1) {
    printf(“Odd\n”);
    }
    else {
    printf(“Even\n”);
    }
    return 0;
    }
    ———————————-


    Share on Facebook Delicious Bookmark this on Delicious

    Blackberry LED Programming

    Aug. 25, 2009

    This article show how to access LED on blackberry handheld.

    For LED programming, we need to import net.rim.device.api.system.LED.

    LED (continue reading…)


    Share on Facebook Delicious Bookmark this on Delicious

    BlackBerry Programming

    Jul. 29, 2009

    The Blackberry platform is Java® based, and there are number of different tools that you can
    use to develop your applications. This tutorials only show basic programming for Blackberry® application. We assume that you’re not beginner in programming. Java® language is mandatory. This tutorials use Windows® OS, but you may develop use other OS. (continue reading…)

    Share on Facebook Delicious Bookmark this on Delicious

    Exec PHP

    May. 24, 2009

    This article is for wordpress.org users.

    Exec-PHP is the best plugin i ever use. Just download from http://bluesome.net/post/2005/08/18/50/.
    Exec-PHP enable you to run PHP and script from your blog. It’s easy to install, just follow the note. If you’re PHP programmer and want to enhance your blog, it’s recommended to install this plugin to your wordpress blog.

    Technically Exec-PHP executes code inside of arbitrary text by wrapping the whole text into “? > < ?” php tags and hand it over to the PHP eval() function. This requires that the executable code itself is encapsulated into “< ? php ? >” tags. By that no parsing of your code needs to be done by the plugin itself.

    Difference to similar plugins

    There are a lot of PHP plugins available all doing slightly different things. The following list was gathered back in the beginning of 2007 and may not be complete and probably outdated because some of the plugins may have been updated, including more features. Therefore the names of the compared plugins are given including the version number.

    Sniplets
    The Sniplets plugin by John Godley seems to be a good alternative to Exec-PHP. Although it is harder to configure than Exec-PHP, you may gain some improvements in security due to the way the Sniplets plugin is working.

    RunPHP 0.2.2 (Mark Somerville)
    The RunPHP plugin by Mark Somerville uses XHTML tag syntax to separate code from HTML. It does strange conversions to “fix” texturized posts and does not support WordPress’ 2.x roles and capabilites system.

    RunPHP 2.1.1 (James Van Lommel)
    The RunPHP plugin by James Van Lommel creates parsing errors with most of the test code below.

    PHP Exec 1.7
    The PHP Exec plugin by Priyadi Iman Nurcahyo uses XHTML tag syntax to separate code from HTML. It does strange conversions to “fix” texturized posts.

    EzStatic 3
    The EzStatic 3 plugin by Owen Winkler


    Share on Facebook Delicious Bookmark this on Delicious