edwin

Download A Compressed Attachment (Zip, Rar or 7Z) on GMail

I want to download a compressed file that i’ve sent several years ago, but somehow google disabled it, and gives an “anti virus warning”. And it happen for all my email with compressed attachments files, such as .zip, .rar and also .7z.

compressed download

Well, the workaround is quite simple, im opening my email using my Android GMail client , and then save my attachment to Google Drive.

7zip

From Google Drive, i can easily download my attachment freely.
google drive

Hopefully it can help other people. 😀

Creating Alphabet Numbering on Jasper Report

Usually jasper report provide a numbering, accessible using REPORT_COUNT variable, but today my friend Edward Barchia asked me something interesting, how can i create a simple numbering using alphabet instead of number. Well basically, it’s actually quite easy.

Below is the image, how i do it.
jasperreportcharat

Here is my complete jasper xml file,

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="97dae3d4-5e81-4825-b4e7-cf3d1f77190f">
	<property name="ireport.zoom" value="1.2100000000000002"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="42"/>
	<queryString language="SQL">
		<![CDATA[select * from testing]]>
	</queryString>
	<field name="id" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="name" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="address" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="79" splitType="Stretch"/>
	</title>
	<pageHeader>
		<band height="35" splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band height="20" splitType="Stretch">
			<staticText>
				<reportElement x="50" y="0" width="100" height="20" uuid="f68bc18a-5471-4d4f-89ed-34d98bb06b6e"/>
				<text><![CDATA[name]]></text>
			</staticText>
			<staticText>
				<reportElement x="150" y="0" width="100" height="20" uuid="155f7ce1-e70c-4d93-8ebc-bad45d9f0ae1"/>
				<text><![CDATA[address]]></text>
			</staticText>
			<staticText>
				<reportElement x="0" y="0" width="50" height="20" uuid="48b8e6ef-1efd-4233-98f5-b2da6d273333"/>
				<text><![CDATA[No]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="20" splitType="Stretch">
			<textField>
				<reportElement x="50" y="0" width="100" height="20" uuid="3ffd3edf-b950-4dd9-8f13-ac8942e5bb8e"/>
				<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="150" y="0" width="100" height="20" uuid="236aec6c-34dc-4a54-ae2d-086c2a23786c"/>
				<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="0" y="0" width="50" height="20" uuid="704b47d3-7dca-4f33-950a-a3efd0fb764b"/>
				<textFieldExpression><![CDATA["abcdefghijklmnopqrstuvwxyz".charAt( $V{REPORT_COUNT}-1 )]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band height="45" splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band height="54" splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band height="42" splitType="Stretch"/>
	</summary>
</jasperReport>

[Java] SMS Gateway dengan Modem Zoglab Q2687RD

Baru-baru ini gw dapet kerjaan untuk membuat suatu sistem notifikasi yang terhubung dengan modem SMS, kebetulan modem yang dipakai adalah modem dengan merk Zoglab seri Q2687RD. Awalnya gw pikir menggunakan metode konvensional, menggunaan 7bit sms gateway ala-ala skripsi jaman gw masih kuliah, dan ternyata rada berbeda format AT Command-nya.

Oh ya, sebelumnya ini adalah wujud modemnya. Sekilas agak aneh, karena ada colokan power dibelakangnya tapi waktu membeli engga dapet kabel powernya. Ternyata powernya bisa lewat kabel USB.

modem zoglab

Oke, berikut adalah class java yang gw gunakan untuk testing sending SMS, kebetulan gw menggunakan library RXTXcomm.jar.

package com.edw.commportchecker;

import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.io.OutputStream;
import java.util.Enumeration;

public class Main {

    private OutputStream outputStream;
    private SerialPort serialPort;

    private void doSomething()
            throws Exception {
        Enumeration portList = CommPortIdentifier.getPortIdentifiers();
        System.out.println(portList.hasMoreElements());
        while (portList.hasMoreElements()) {
            CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
            if (portId.getPortType() == 1) {
                System.out.println("connecting to " + portId.getName());
            }
            // kebetulan modem kedetect sebagai COM3
            if (portId.getName().equalsIgnoreCase("COM3")) {
                this.serialPort = ((SerialPort) portId.open("SMSGateway", 2000));
            }
        }


        this.serialPort.setSerialPortParams(9600, 8, 1, 0);
        this.serialPort.setFlowControlMode(0);

        this.outputStream = this.serialPort.getOutputStream();

        System.out.println("sending");

        // gunakan prefix +62, contoh : +62856727xxxx 
        // agak aneh nih, sebelumnya tanpa prefix "+" jalan, tapi ditengah jalan tiba2 jadi ga jalan T_T
        String nomerHp = ""; 
        
        // content sms yang akan dikirim
        String contentSMS = "ini isi sms-nya";
        
        sendToStream("AT\r");
        sendToStream("AT+CMGF=1\r");
        sendToStream("AT+CMGS=\""+nomerHp+"\"\r\n");
        sendToStream(contentSMS);
        sendToStream("\032");

        System.out.println("finish");

        System.exit(1);
    }

    private void sendToStream(String content) throws Exception {
        System.out.println(">" + content);

        this.outputStream.write(content.getBytes());
        this.outputStream.flush();

        Object o = new Object();
        synchronized ( o ) {
            o.wait(1500L);
        }
    }

    public static void main(String[] args) {
        Main main = new Main();
        try {
            main.doSomething();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

[Java] Create a Simple Http Get Request with GZip Compression Handling using Apache Httpclient

Previous Apache HttpClient use various class to handling compressed http response, such as DecompressingHttpClient and ContentEncodingHttpClient. But on the latest version, compression is handled automatically by using HttpClientBuilder class.

Here is my pom file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.edw</groupId>
    <artifactId>Edw</artifactId>
    <version>1</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>
    
    <dependencies>                
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.1</version>
        </dependency>        
    </dependencies>
    
</project>

And this is my java class,

package com.edw.main;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;

public class Main {

    public static void main(String[] args) throws Exception {
        Main main = new Main();
        System.out.println(main.getContent("http://localhost:8085/"));
    }

    private String getContent(String urlToRead) throws Exception {
        HttpEntity resEntity = null;
        try {
            HttpClient httpclient = HttpClientBuilder.create().build();
            HttpGet httpGet = new HttpGet(urlToRead);

            HttpResponse response = httpclient.execute(httpGet);
            resEntity = response.getEntity();

            return EntityUtils.toString(resEntity);
        } finally {
            if (resEntity != null) {
                EntityUtils.consume(resEntity);
            }
        }
    }
}

How to Extract SRT (Subtitle File) From MKV Movie File on Windows

Ive just download a very good, and a highly recommended anime, Digimon Adventure Tri. It can play well on my laptop, but when i put it on my TV, somehow the subtitle is gone. I notice that it happen because the srt got burn inside the video file.

After browsing for a while, i found out that i can extract my srt using MKVToolNix tools. I downloaded it, and using one of its tools, mkvextract.exe, i can extract the subtitles i wanted from my mkv files.

But first, make sure you use mkvinfo.exe to check your mkv information.

C:\Program Files\MKVToolNix>mkvinfo.exe 
        "C:\Users\edw\Downloads\[HorribleSubs] Digimon Adventure tri - 01 [1080p].mkv"

And find track id for subtitles.

| + A track
|  + Track number: 3 (track ID for mkvmerge & mkvextract: 2)
|  + Track UID: 3
|  + Track type: subtitles
|  + Lacing flag: 0
|  + Codec ID: S_TEXT/ASS
|  + CodecPrivate, length 1934

In this scenario, my subtitle track id is 2 and subtitle format is .ass

Okay, whit that information, i can start to extracting my subtitle file.

C:\MKVToolNix>mkvextract tracks 
        "C:\Users\edw\Downloads\[HorribleSubs] Digimon Adventure tri - 01 [1080p].mkv" 
        2:"E:mysubtitle.ass"

It will extract subtitle from “Digimon Adventure tri – 04 [1080p].mkv” and put the subtitle on E:\ with named mysubtitle.ass. You can convert .ass file into .srt file easily using online converter tools.