Pages

Saturday, February 11, 2012

Ways to convert several DOS files into UNIX file

Usually I use the same vim scripts in Windows and Linux. Sometimes I copy the scripts from Windows to Linux and they still in dos format. Therefore when the scripts executed some errors come out because of the difference between Windows' and Linux's carriage line format.

Below is my way to convert several dos files into unix file

Using dos2unix

Using dos2unix tool is the simplest way, I just run below command $ find ~/.vim -name "*.vim" -print0 | xargs -0 dos2unix

Using fromdos

To use fromdos tool I need to make a bash script like below: #!/bin/sh list=`find ~/.vim -name "*.vim" -print` for files in $list; do fromdos < $files > $files-x mv $files-x $files done

Saturday, February 12, 2011

Changing Time Zone in Slackware 13.1

Travelling to different countries makes you experience different timezone, it can some hours ahead or after of your country timezone. Sometimes I experience this!, at the first time I was ignoring the time difference in my laptop. But this time not.

So below is the steps to change your timezone configuration in Slackware 13.1, you should do these steps as root.

  1. Change time zone links in /etc: "/etc/localtime-copied-from" to your current timezone in /usr/share/zoneinfo/xxx/xxx (xxx is depends on your timezone area)
    # ln -sf /usr/share/zoneinfo/xxx/xxx /etc/localtime-copied-from
  2. Replace your "/etc/localtime" with your current "/etc/localtime-copied-from"
    # cp -rf /usr/share/zoneinfo/xxx/xxx /etc/localtime
  3. Update your time using ntp server (pool.ntp.org)
  4. # ntpdate pool.ntp.org
    # hwclock -w

Isn't it simple? In my opinion this's simple, but sometime we can't do the simplest thing.


Tuesday, August 17, 2010

Vim 7.3 Released

On 16 August 2010, I had received an email from Vim google mailing list, this mail announce that Vim 7.3 was released to public finally. You can check below quote for release note by Bram Moolenaar.


Hello Vim users,

Announcing:  Vim (Vi IMproved) version 7.3

This is a minor release of Vim.  It consists of Vim 7.2 plus all
patches, updated runtime files and some more, see below.  It has been
two years since the 7.2 release, thus it's not that "minor".  But not
"major" either.  Something in between, don't know how to call that.

The most notable additions since 7.2:
- Persistent undo and undo for reload
- Blowfish encryption, encryption of the swap file
- Conceal text
- Lua interface
- Python 3 interface

Once you have installed Vim 7.3 you can find all the details about the
changes since Vim 7.2 with:
        :help version-7.3

Gratitude
---------

If you like Vim, this is the way to say thanks:
http://iccf-holland.org/clinic.html

Where to get it
---------------

The best way to obtain the latest Vim 7.3 is using Mercurial.
Summary:
        hg clone https://vim.googlecode.com/hg/ vim
        cd vim/src
        hg update vim73
        make
More information here: http://www.vim.org/mercurial.php

All downloadable files can be found below this directory:
        ftp://ftp.vim.org/pub/vim/

Direct link to the MS-Windows self-installing executable:
        ftp://ftp.vim.org/pub/vim/pc/gvim73.exe

Information about which files to download for what system:
        http://www.vim.org/download.php

A list of mirror sites can be found here:
        http://www.vim.org/mirrors.php

UNIX:
unix/vim-7.3.tar.bz2           sources + runtime files, bzip2 compressed

MS-WINDOWS one-size-fits-all:
pc/gvim73.exe                  installer for GUI and console executables,
                               includes all runtime files, many features

VARIOUS:
doc/vim73html.zip              help files converted to HTML

MS-WINDOWS separate files:
pc/vim73rt.zip                 runtime files
pc/gvim73.zip                  GUI binary for Windows 95/98/NT/2000/XP
pc/gvim73ole.zip               GUI binary with OLE support
pc/gvim73_s.zip                GUI binary for Windows 3.1 (untested)
pc/vim73d32.zip                console version for MS-DOS/Windows 95/98
pc/vim73w32.zip                console version for Windows NT/2000/XP
pc/vim73src.zip                sources for PC (with CR-LF)

DIFFS TO PREVIOUS RELEASE:
unix/vim-7.2-7.3.diff.gz               sources + runtime files
unstable/unix/vim-7.3f-7.3.diff.gz     sources + runtime files

Omitted in this version are:
- Extra and lang archives, these are now included in the main source
  and runtime archives.
- The 16-bit DOS, OS/2 and Amiga versions, these are obsolete.

Mailing lists
-------------

For user questions you can turn to the Vim mailing list.  There are a
lot of tips, scripts and solutions.  You can ask your Vim questions, but
only if you subscribe.  See http://www.vim.org/maillist.php#vim

If you want to help Vim development, discuss new features or get the
latest patches, subscribe to the vim-dev mailing list.  See
http://www.vim.org/maillist.php#vim-dev

Subject specific lists:
Multi-byte issues: http://www.vim.org/maillist.php#vim-multibyte
Macintosh issues:  http://www.vim.org/maillist.php#vim-mac

Before you ask a question you should search the archives, someone may
already have given the answer.

Reporting bugs
--------------

Send them to ...@vim.org>.  Please describe the problem precisely.
All the time spent on answering mail is subtracted from the time that is
spent on improving Vim!  Always give a reproducible example and try to
find out which settings or other things influence the appearance of the
bug.  Try starting without your own vimrc file: "vim -u NONE".  Try
different machines if possible.  See ":help bugs" in Vim.  Send me a
patch if you can!

Happy Vimming!

--
Q: Should I clean my house or work on Vim?
A: Whatever contains more bugs.

 /// Bram Moolenaar -- B...@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

Thursday, August 5, 2010

Bad Evince Font in Slackware

When I install evince on my Slackware, sometimes I encounter a strange problem which is the font is not display correctly or looks weird, as like the picture below:


You can see that there are fonts look too bold and inconvenient to read. After diving in google, I found that the problem comes from the Nimbus font in slackware package. To check and fix it you can follow instructions below:
  • Check fonts in pdf file
  • $ pdffonts file.pdf
    name                                 type      emb sub uni object ID
    ------------------------------------ --------- --- --- --- ---------
    Times-Italic                         Type 1    no  no  no       5  0
    Times-Roman                          Type 1    no  no  no       7  0
    Times-Bold                           Type 1    no  no  no      13  0
    Courier-Bold                         Type 1    no  no  no      18  0
    XOEOHB+CMSY10                        Type 1    yes yes no      21  0
    Courier                              Type 1    no  no  no      23  0
    RXRCVR+CMSY7                         Type 1    yes yes no      26  0
    CRMLEZ+NimbusRomNo9L-Regu-Slant_167  Type 1    yes yes no      32  0
    
  • Check"Times" compatible font
  • $ fc-match "times"
    n021004l.pfb: "Nimbus Roman No9 L" "Medium"
    
  • Find n021004l.pfb location
  • $ su
    password:
    # find / -name "n021004l.pfb" -print
    /usr/share/fonts/Type1/n021004l.pfb
    /usr/share/libwmf/fonts/n021004l.pfb
    
  • Download new n021004l.pfb
  • As I get from searching in google, the problem is n021004l.pfb in Slackware package is not updated yet, so we need to replace it with the new one. In this case I'll replace it with the Fedora 13 URW fonts package. You can download the package from http://koji.fedoraproject.org/koji/buildinfo?buildID=138570
    
    
  • Extract the rpm package
  • # rpm2cpio urw-fonts-2.4-9.fc13.noarch.rpm | cpio -idmv 
  • Copy fonts file and reboot
  • # cd usr/share/fonts/default/Type1
    # cp n021004l.pfb /usr/share/fonts/Type1/n021004l.pfb
    # reboot 

After reboot then I check evince display, and the result is like below. There we can see that the font looks better and convenient than before.


I hope this tutorial is helpful.

Monday, July 26, 2010

Get apk from phone

When I do flashing my Samsung Spica for the first time, I lost all of my application. It means I need to download it all again from market and costs my credit. Therefore I need to get my apk from phone, and backup it all to my PC.

After doing some tests and trials based on a clue from my friend. I finally find a way to backup all of applications by downloading all installed apk from the phone, and it's really simple.

Before going further, we need to install android SDK:

  • Download android sdk from here 
  • Extract android sdk zip file to C:\
  • Add this "C:\android-sdk-windows\tools" to windows path in environment variable

And then to allow you accessing /data/app directory, you must have root permission therefore wee need to root the device. You can follow instructions in here to root your device here, but please be careful because it can bricks your device.

When you download applications from market, the system will store the apk files in /Data/app. Base on this information we can pull all of downloaded apk from phone to PC by using adb pull command.

adb pull /data/app "your destination directory"

And you can find all of your downloaded apk in "your destination directory".

Monday, July 19, 2010

PDCurses for MinGW32

As I know MinGW doesn't come with graphic control library, it isn't like borland or turbo which brings conio.h. But you can use curses library for alternative. If you use Linux you can find ncurses library, but if you're windows user you can use PDcurses.

In this tutorial I'll explain how to install PDcurses for MinGW32 compiler in MS Windows. The first things you need are Installed MinGW32 compiler and PDcurses source. You can download MinGW from here and PDcurses from here.

Set up MinGW32
  1. Install MinGW32, don't forget to install 'MinGW make' also (if you don't want to install MSys), in this case I'll install MinGW in C:\MinGW
  2. Set environment path for MinGW bin directory
    • Go to control panel
    • Click System
    • Choose Advanced tab and click "Environment Variables" button
    • Add PATH variable for user, if you have one you can skip this
    • Select PATH variable and Edit
    • In "variable value" text box, add C:\MinGW\bin, and don't forget to use ';' (semicolon) as delimiter
  3. If you didn't install MSys so you need to rename mingw32-make.exe become make.exe
  4. CD C:\MinGW\bin
    RENAME mingw32-make.exe make.exe

Install PDcurses
  1. I assume you have downloaded PDCurses source successfully, in this case I have downloaded PDCurses-3.4.tar.gz
  2. Unpack it by using winrar to C:\ and you will have C:\PDCurses-3.4 directory
  3. Compile win32 PDcurses with DLL
  4. CD C:\PDCurses-3.4\win32
    make -f gccwin32.mak DLL=Y

  5. Copy pdcurses.dll to C:\MinGW\bin
  6. COPY pdcurses.dll C:\MinGW\bin
  7. Copy pdcurses.a to be C:\MinGW\lib\libpdcurses.a
  8. COPY pdcurses.a C:\MinGW\lib\libpdcurses.a
  9. Copy pdcurses header file to C:\MinGW\lib\include
  10. CD ..
    COPY *.h C:\MinGW\include

Test PDcurses
  1. Create test.c
  2. #include <curses.h> int main()
    {
        initscr();
        printw("Hello World !!!\n");
        refresh();
        system("pause");
        endwin();
        return 0;
    }

  3. Compile test.c and check if there is any error
  4. gcc test.c -o test -lpdcurses
  5. Test executable file. If you can see "hello world" it means everything goes well
  6. test.exe

I hope this tutorial will be helpful for who need it.

Wednesday, June 9, 2010

Upgrade to Slackware 13.1

Slackware 13.1 has been released on 24 May 2010. There are updates for some packages and kernel. Usually every Slackware released I will choose fresh install before use it, but now I won't choose that, I'll choose to upgrade.

Before going further. To keep my configuration files safe I need to backup my /etc folder. In this case I backup it by creating iso image of /etc and keep the owner and permission of those files. You can do below method for your important files aswell.
# mkisof -o ~/etc-backup.iso -R /etc
And then check it
# mount -t iso9660 -o loop=/dev/loop0 ~/etc-backup.iso /mnt/tmp
# ls -ll /mnt/tmp


Next step is based on UPGRADE.TXT instructions, you can find it in root directory of Slackware distribution package. There area some steps to do to Upgrade your slackaware:
  • Create packages folder
  • Switch to single user
  • Upgrade package utility and related tools
  • Upgrade glibc shared libraries
  • Upgrade packages and install new packages
  • Remove obsolete packages
  • Fix or install new configuration files
  • Finishing
  • Reboot

Create packages directory
You need to create directory which contains Slackware 13.1, you can download it one by one or download it in ISO format. In my case I download ISO file from one of this mirror and extract it into "Slackware packages" directory
# mount -t iso9660 -o loop=/dev/loop0 slackware-13.1-install-dvd.iso /mnt/tmp
# mkdir /slackware
# cp -rf /mnt/tmp/* /slackware/*

Basically I can use /mnt/tmp as "Slackware packages directory" but I prefer to copy it to another directory as my "Slackware packages" directory. It's only for safety and stability.

Switch to single user
I just do a simple command to switch into single user
# telinit 1

Upgrade package utility and related tools
Before going further we need to upgrade tools that related to packaging
# upgradepkg /slackware/a/pkgtools-*.tgz
# upgradepkg /slackware/a/tar-*.tgz
# installpkg /slackware/a/xz-*.tgz
# upgradepkg /slackware/a/findutils-*.txz


Upgrade glibc shared libraries
# upgradepkg /root/slackware/a/glibc-solibs-*.t?z

Upgrade packages and install new packages
If you want to upgrade and install all new packages, you can use command below
# upgradepkg --install-new /root/slackware/*/*.t?z
If you want to uprage and install new package based on package group you can use command below, just add and remove package group in looping.
#!/bin/sh
for dir in a ap d e f k kde l n t tcl x xap y ; do
    ( cd $dir ; upgradepkg --install-new *.t?z )
done

You can check the description of those package group below:
A : The base system.
AP : Various applications that do not require the X Window System.
D : Program development tools.
E : GNU Emacs.
F : FAQs, HOWTOs, and other miscellaneous documentation.
K : The source code for the Linux kernel.
KDE : The K Desktop Environment.
KDEI : Language support for the K Desktop Environment.
L : System libraries.
N : Networking programs.
T : teTeX document formatting system.
TCL : The Tool Command Language, Tk, TclX, and TkDesk.
X : The base X Window System.
XAP : X applications that are not part of a major desktop environment.
Y : Games (the BSD games collection, Sasteroids, Koules, and Lizards).

Remove obsolete packages
You can remove obsolete packages in Slackware 13.1 by using command below:
#removepkg bluez-libs bluez-utils cupsddk device-mapper epic4 gqview \
     kdelibs-experimental lbxproxy libgtkhtml liblbxutil libungif \
     libv4l loadlin mpg321 mplayerthumbs proxymngr xf86-input-citron \
     xf86-input-elographics xf86-input-fpit xf86-input-hyperpen \
     xf86-input-mutouch xf86-video-newport xf86-video-xgixp


Fix or Install New Configuration file
Upgrading means you will have new configuration files in etc, if you brave enough you can apply script below to apply it.
#!/bin/sh
cd /etc
find . -name "*.new" | while read configfile ; do
if [ ! "$configfile" = "./rc.d/rc.inet1.conf.new" \
    -a ! "$configfile" = "./rc.d/rc.local.new" \
    -a ! "$configfile" = "./group.new" \
    -a ! "$configfile" = "./passwd.new" \
    -a ! "$configfile" = "./shadow.new" ]; then
    cp -a $(echo $configfile | rev | cut -f 2- -d . | rev) \
        $(echo $configfile | rev | cut -f 2- -d . | rev).bak 2> /dev/null
    mv $configfile $(echo $configfile | rev | cut -f 2- -d . | rev)
fi
done

You should upgrade/merge your man.conf file and vimrc with these file:
/usr/man/man.conf.new
/usr/share/vim/vimrc.new


Reboot
# reboot

Finishing
If you've installed some packages that are not in Slackware default, you need to recheck it functionality, and if you find problem I think you need to recompile the software or it's dependency.