Friday, March 10, 2017

Install Sketchup 2017 64 bits on Linux Ubuntu 16.04 64 bits

Install Sketchup 2017 64 bits on Linux Ubuntu 16.04 64 bits:

1.Enable 32 bit architecture:
$sudo dpkg --add-architecture i386 

2. Set wine PPA
$sudo add-apt-repository ppa:wine/wine-builds

Update repository
$sudo apt-get update

3. Install wine newest staging branch version
$sudo apt-get install --install-recommends winehq-staging

4. Ensure we get a 64bits wine, edit file ~/.profile and locate for text:
export WINEARCH=
If the value is win64 you are good, if the value is win32 change it to win64. Save the file.

Ensure the environment variable also set to win64 by typing command:
$export WINEARCH=win64

5. Download winetricks:

$wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
   Don't forget to set the attribute so it is executable
$chmod +x winetricks

6. Run winetricks
$./winetricks

Inside winetricks:
Choose Select the default wineprefix, click OK

Choose Install a Windows DLL or component, click OK

Choose vcrun2015, click OK

...after vcrun2015 installation complete
Choose winecfg, click OK
Choose tab Applications, set Windows version to Windows 8.1

Choose tab Libraries, Add New override for library: mfc140u.dll

Click OK

Click OK

Click Cancel to quit winetricks

7. Download Sketchup 2017 Make 64 bit from https://www.sketchup.com/download/all

8. From nautilus, locate file SketchUpMake-en-x64.exe, highlight the file, right click, Open with Archive Manager and then extract file SketchUp2017-x64.msi

If Archive Manager says "An error occured while loading the archive", you need to install 7z first.

$sudo apt-get install p7zip-full


9. From terminal run:
$wine explorer

10. Locate file SketchUp2017-x64.msi and double click to install.

11. In Destination folder change the installation folder to

C:\Program Files\SketchUp\SketchUp 2017\

Click Next and then Install.

12. If you want to use the Professional you need to install Microsoft .Net Framework 4.5.2 (Offline installer), download from here:

https://www.microsoft.com/en-us/download/details.aspx?id=42642

After download install the file NDP452-KB2901907-x86-x64-AllOS-ENU.exe

13. Enjoy Sketchup in linux.

Saturday, October 22, 2016

POSTGRESQL: Dealing with 'current transaction is aborted, commands ignored until end of transaction block' in Lazarus/Delphi

Scenario: 
Programming Environment: Lazarus/Delphi
Database: PostgreSQL
DB Component: Zeos

Problem:

You have a form displaying a table content in a grid. It is a typical data form where user can insert, update or delete record.

When user inserting record which fails going through Table integriry constraints (foreign key, unique constraint, check constraints etc), postgresql will throw exception: current transaction is aborted, commands ignored until end of transaction block. After this, all operation is not possible except closing the form and losing all modification you might have done.

Solution:
Define events of the query component, FDBConnection is db the connection component.

BeforePost and BeforeDelete events:
Self.FDBConnection.ExecuteDirect( 'SAVEPOINT mysavepoint');

AfterPost and AfterDelete events:
Self.FDBConnection.ExecuteDirect( 'RELEASE SAVEPOINT mysavepoint');

OnPostError and OnDeleteError events:
Self.FDBConnection.ExecuteDirect( 'ROLLBACK TO SAVEPOINT mysavepoint');

Note: you can change mysavepoint with any valid identifier name.

Sunday, February 22, 2015

NOTEPAD++ SOURCECOOKIFIER SETTING FOR CLIPPER LANGUAGE

Notepad++ is a very excellent programmer editor for Windows. It has plugin system which enhances it's functionality. Sourcecookifier is a plugin I like very much, it is a simple plugin which shows the outline of your source code.

The screenshot below shows a pascal (delphi) source code. We can easily see the structure of the source code, and we can go to a particular method/function just by one click.


Sourcecookifier recognizes several programming languages, but it does not support Clipper language. Fortunately, it is very easy to add Clipper configure. Follow this step:

  1. Click setting icon (the yellow gear icon) on the sourcecookiefier window.

  2. Click Language Settings
  3. On the setting form, type Clipper on the language box and click add.


  4. Set the file extension setting, add .prg to the extenson box


  5. On Tag Type choose any letter you like. Here I add “f” for “function” (any letter will be fine)


  6. On Appearance box, you can write the description, choose Icon etc. It is not too important, I just put [function] in description and leave the other fields as it is.

  7. Set the regular expression, fill the input and output as follow
    Input: (^(FUNC.*)[ \t]*)(([a-zA-Z0-9_]+))
    Output: \1
    Clear the case sensitive box and click Add



  8. Repeat step 5 to step 7 to define additional keyword regexes for static function, procedure, static procedure, create class and method. Here are the regexes:

    static function: Input = (^(STAT.*)(FUNC.*)[ \t]*)(([a-zA-Z0-9_]+))
    Output = \1
    procedure: Input = (^(PROC.*)[ \t]*)(([a-zA-Z0-9_]+))
    Output = \1
    static procedure: Input = (^(STAT.*)(PROC.*)[ \t]*)(([a-zA-Z0-9_]+))
    Output = \1
    create class: Input = (^(CREA.*)(CLAS.*)[ \t]*)(([a-zA-Z0-9_]+))
    Output = \1
    method: Input = (^(METH.*)[ \t]*)(([a-zA-Z0-9_]+))
    Output = \1

  9. The result is like this.


    It is not perfect yet, in the example above “METHOD Init(...” scanned as “METHOD Ini”, I still don't know how to resolve.




Saturday, September 21, 2013

Install PCI Parallel card murah meriah di Linux.

Baru-baru ini, parallel port onboard di salah satu komputer klienku rusak. Lalu dibelikan Parallel card PCI made in China yang murah meriah. Card ini tidak ada merknya cuma ada tulisannya PCI60806A dan cuma terdiri dari 1 IC :)

Tapi setelah dipasang ternyata parallel card ini tidak dikenali di ubuntu, sehingga kemarin terpaksa komputernya di bawa ke rumahku untuk opname. Anehnya, output dari perintah lspci -v mengatakan bahwa card ini adalah serial port:

03:00.0 Serial controller: Device 4651:7073 (rev 10) (prog-if 02 [16550])
Subsystem: Device 4651:7073
Flags: medium devsel, IRQ 20
I/O ports at df00 [size=8]
I/O ports at de00 [size=8]
Kernel driver in use: serial

Dari hasil googling ternyata ini memang kasus umum pada pci parallel card murah meriah, card-card ini sebenarnya mempunyai 2 fungsi interface, serial interface dan parallel interface. I/O port pertama (df00) adalah port untuk Serial Port sedangkan port kedua (de00) adalah untuk Parallel port.

Sekarang kita coba gunakan driver parallel port linux (partport_pc) untuk mengakses port 0xde00 di atas.
  1. Unload terlebih dahulu driver lp dan parport_pc
    # rmmod lp
    # rmmod parport_pc
  2. Reload parport_pc dengan io address de00
    # cd /lib/modules/`uname -r`/kernel/drivers/parport
    # insmod parport_pc.ko io=0xde00
  3. Reload driver lp
    # cd /lib/modules/`uname -r`/kernel/drivers/char
    # insmod lp.ko
  4. Check dengan dmesg
    # dmesg | grep parport
    dan ini outputnya:
    [ 10.650355] parport0: PC-style at 0xde00, irq -227213512 [PCSPP,TRISTATE]
    [ 10.650362] parport0: irq -227213512 in use, resorting to polled operation
    [ 10.736222] lp0: using parport0 (polling).

Masalahnya, setting ini tidak permanen, artinya jika direboot akan kembali ke kondisi semula. Untuk itu kita bisa membuat initialization script yang bisa diletakkan di /etc/init.d/

Tetapi solusi yang lebih baik adalah dengan membuat konfigurasi di directory /etc/modprobe.d, buat sebuah file dengan sembarang nama tapi extensionnya .conf di directory tersebut. Isi file tsb. adalah:

options parport_pc io=0xde00

Maka setiap kali komputer booting, driver parallel port akan diload dengan option di atas.


Monday, September 2, 2013

Install Windows Printer Fuji Xerox DocuPrint P205 b di Ubuntu

Kemarin ada yang baik hati memberikan aku printer laser Fuji Xerox type DocPrint P205b. Masalahnya, printing system di Ubuntu (CUPS) tidak ada driver untuk printer ini. Situs Fuji Xerox pun (http://www.fujixeroxprinters.com.au/en/Downloads.aspx?product=9933) tidak menyediakan printer driver untuk linux, karena ternyata printer ini adalah GDI printer.

GDI printer biasanya merupakan printer murah meriah, karena dia tidak mempunyai 'otak' untuk memproses image (rasterize). Pemrosesan image diserahkan ke operating system. Oleh karena itu printer-printer semacam ini biasanya hanya bisa dipakai di Windows saja.

Namun, dunia linux benar-benar menakjubkan – hampir tidak ada yang mustahil di linux. Setelah searching di internet, akhirnya aku menemukan sebuah situs yang menyediakan driver untuk printer ini, namun untuk menginstallnya tidak sekedar mengcopy file drivernya (.ppd) saja. Silahkan cek http://foo2hbpl.rkkda.com/ .

Di bawah ini adalah langkah-langkah untuk menginstallnya di Ubuntu. Untuk distro-distro lain silahkan ikuti petunjuk di situs tsb:

  1. Download source dari package foo2zjs dari http://foo2zjs.rkkda.com/foo2zjs.tar.gz. Di ubuntu, sebenarnya package ini sudah terinstall, namun kita tidak dapat memakainya.
  2. Extract:
    $tar zxf foo2zjs.tar.gz
  3. Uninstall package foo2zjs bawaan ubuntu:
    $cd foo2zjs
    $make uninstall
  4. Uninstall package system-config-printer-udev:
    $sudo apt-get remove system-config-printer-udev
  5. Install dependencies yang dibutuhkan dan compile:
    $sudo apt-get install build-essential tix foomatic-filters groff dc
    $make
  6. Install package foo2zjs-nya:
    $sudo make install install-hotplug cups
  7. Setelah langkah ini kita bisa menginstall driver printernya. Di komputer penulis, install tidak bisa dijalankan lewat menu Install printer seperti biasa, namun harus lewat web interface.
  8. Hubungkan kabel USB printer ke komputer dan nyalakan printer.
  9. Buka browser anda dan buka web interface dari CUPS: https://127.0.0.1:631
  10. Klik Menu Administration, lalu klik Add Printer. Pilih printernya lalu ikuti sampai langkah di mana kita diminta memilih drivernya. Pada langkah ini, klik “Provide a PPD file” dan arahkan filenya ke /usr/share/cups/model/Fuji_Xerox-DocuPrint_P205.ppd.gz
  11. Selesai, printer bisa digunakan.
UPDATE: ubuntu 14.04 bisa mengenali printer ini out of box dengan baik tanpa harus menjalankan langkah-langkah di atas

Saturday, January 28, 2012

Creating custom build wine deb package

In one of my projects, I need to install custom build of wine to several computers running ubuntu.
Hence, I had to get the sources, apply the patch files and then compile the source.  Doing this for 1 computer is okay, however repeating this to several computers is a huge waste of time.

The solution is compiling once and then build a debian package (*.deb), so for the other computers we just install the debian package file. Fortunately, making a debian package is very-very easy. Here is what I did:


Saturday, January 14, 2012

Merge several pdfs in ubuntu

Some times we need to merge several pdf files into 1 pdf file. Fortunately, it is very easy to do it in ubuntu. For instance, I have 2 pdf files: proposal_rpi.pdf and program_qc.pdf.

Here is how I merge these 2 files into 1 pdf file: proposal_jan_15_2012.pdf:


bambang@bambang-notebook:~$ gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=proposal_jan_15_2012.pdf -dBATCH proposal_rpi.pdf program_qc.pdf