Thursday, June 26, 2014

Using netinstall to update MikroTik


  1. Download netinstall (http://www.mikrotik.com/download)
  2. Download the package (http://www.mikrotik.com/download)
  3. Run/Open netinstall
  4. Click "Net Booting" button
  5. Check "Boot Server Enabled"
  6. Fill client IP address with 192.168.88.10 (in this example my computer IP address is 192.168.88.9)
  7. Connect router board and PC via ether1
  8. Turn off the router board
  9. User paper clip or something to push the reset button on the router board
  10. Push and hold the reset button, turn on the router board, stay hold the reset button until the act indicator stop flashing
  11. Wait 10-20 seconds it should detected from netinstall
  12. Select the package and click install button

Wednesday, June 25, 2014

Grails Jasper plugins - direct pdf output

I use jasper plugin (http://grails.org/plugin/jasper) in my grails application. I want to send direct pdf file to the browser.

package com.jasper

import org.codehaus.groovy.grails.plugins.jasper.JasperExportFormat
import org.codehaus.groovy.grails.plugins.jasper.JasperReportDef

class LabController {

    def jasperService
    def directpdf() {

        def reportDef = new JasperReportDef(name:'mbarang.jrxml', fileFormat:JasperExportFormat.PDF_FORMAT)
        response.contentType = 'application/pdf'
        response.outputStream << jasperService.generateReport(reportDef).toByteArray()
        return(false);
    }
}

Tuesday, May 20, 2014

Using DOMPDF in Yii


  1. Download dompdf : https://code.google.com/p/dompdf/
  2. Extract and copy dompdf folder to protected\vendor
  3. Add the following command to the top of controller that will using dompdf
Yii::import('application.vendor.*');
require_once('dompdf/dompdf_config.inc.php');
Yii::registerAutoloader('DOMPDF_autoload');
  1. Then we should can used like this
 public function actionDompdf() {
...
  $pdf = new DOMPDF();
...
 }

I think we can use the same way to including/import another library

Monday, April 14, 2014

Reset mikrotik to factory default using reset button

1. turn off mikrotik, press and hold button reset (using paper clip or something)
2. apply power (plug the device power), and wait until the ACT LED starts flashing. Now release the button to clear configuration.

Note: If you wait until LED stops flashing, and only then release the button - this will instead launch Netinstall mode, to reinstall RouterOS.

Sunday, February 9, 2014

Java Play MP3 File

1. Download Java Media Framework (JMF) from : http://www.oracle.com/technetwork/java/javase/download-142937.html
2. Download MP3 Plugin from : http://www.oracle.com/technetwork/java/javase/download-137625.html or http://pscode.org/lib/mp3plugin.jar
3. Code for playing the mp3 file is like :


import javax.media.Manager;
import javax.media.Player;
import javax.media.Format;
import javax.media.MediaLocator;
import javax.media.PlugInManager;
import javax.media.format.AudioFormat;

...
        Format input1 = new AudioFormat(AudioFormat.MPEGLAYER3);
        Format input2 = new AudioFormat(AudioFormat.MPEG);
        Format output = new AudioFormat(AudioFormat.LINEAR);

        Format[] formatIn = new Format[2];
        formatIn[0] = input1;
        formatIn[1] = input2;

        Format[] out = new Format[1];
        out[0] = output;

        File mp3file = new File("a.mp3");

        PlugInManager.addPlugIn(
            "com.sun.media.codec.audio.mp3.JavaDecoder",
            formatIn,
            out,
            PlugInManager.CODEC
        );
        try{
            Player player = Manager.createPlayer(new MediaLocator(mp3file.toURI().toURL()));
            player.start();
        }
        catch(Exception ex){
            ex.printStackTrace();
        }
...

Thursday, December 19, 2013

How to List All Installed Applications From the Command Line

One simple command to list all installed application :
wmic product

We can also save them into the .csv file with this comamnd :
wmic product get /format:csv > Software_%Computername%.csv

If this command failed with this error : Invalid XSL format (or) file name.
You should change the Regional and Language to English (US) and re-run the command it should be generated file like : Software_COMPUTERNAME.csv

Reference : http://www.sepago.de/e/helge/2010/01/14/how-to-list-all-installed-applications-from-the-command-line

Friday, October 25, 2013

Grails GORM mapping id column using sequence

I work with grails 2.2.4 and legacy database. The legacy database is using postgreSQL. The primary key filed is hdsj_id (bigserial).


class TableHeaderSuratJalan {

 // a lot of field
 ...

 static mapping = {
  id column: "hdsj_id", generator: "sequence", params: [sequence:"table_header_surat_jalan_hdsj_id_seq"]
  version false
 }

}



We need to specify the sequence name, in this example my sequence's name is table_header_surat_jalan_hdsj_id_seq. By default grails will use hibernate_sequence