terça-feira, 16 de dezembro de 2014

MacOS - how to accentuate the words

Well, when you want to accentuate and not have a special keyboard, you need to use this short keys:

For letter with ^ = option + i and letter
For letter with ~ = option + n and letter
For letter with ' = option + e and letter
For letter with ` = option + ` and letter
For letter ç = option + c

But if you want to do different, go to System Preferences/Language and then select Text/Input sources, after check the box for US International PC. If you don't use multiple keyboard, delete the others keyboard from list and clear the box for Show Input Menu in Menu Bar.  


Voalá, you ready to use! :))


terça-feira, 26 de agosto de 2014

Unix - how you can split a file to n-files?

You could use split command in unix:

split -l[max line number per file] file [prefix]

The default will create PREFIXaa, PREFIXab, ..

If you whan to exchange the lengh of suffixes, use -a [numer]. Will create PREFIXaaaa, PREFIXaaab,... If -a 4.
 

Example to split readme.txt that have 1000 lines into 10 files with name new_000 at new_009

split -l 100 -d 2 readme.txt new_


The man page:

       Output  fixed-size  pieces of INPUT to PREFIXaa, PREFIXab, ...; default
       size is 1000 lines, and default PREFIX is 'x'.  With no INPUT, or  when
       INPUT is -, read standard input.

       Mandatory  arguments  to	 long  options are mandatory for short options
       too. 
 -a, --suffix-length=N
	      use suffixes of length N (default 2) 
 -b, --bytes=SIZE
	      put SIZE bytes per output file 
 -C, --line-bytes=SIZE
	      put at most SIZE bytes of lines per output file 
 -d, --numeric-suffixes
	      use numeric suffixes instead of alphabetic 
-l, --lines=NUMBER
	      put NUMBER lines per output file 
 --verbose
	      print a diagnostic to standard error  just  before  each	output
	      file is opened 
 --help display this help and exit 
 --version
	      output version information and exit 
SIZE may have a multiplier suffix: b for 512, k for 1K, m for 1 Meg. 

quinta-feira, 8 de maio de 2014

VIM: using accent in portuguese

How you can see and use accent in VIM for portuguese language?
Como ver e usar acentuação no VIM para língua portuguesa?

Have two way to do this in *Unix.

1. In Bash profile (~/.bashrc), set the environment variable LANG to latin1 or one of this below:

  • latin1
  • pt_BR.UTF-8
  • iso-8859-1
  • utf-8


2. In VIM profile (~/.vimrc)

  • set encoding=latin1
  • set fileencodings=latin1
  • set termencoding=latin1
  • set nocompatible


You can test in terminal to see if it is ok:

in bash:
    export LANG=latin1
    vim
    write something with accent (e.g. Português)

in vim:
    :set encoding=latin1
    write something with accent (e.g. Português)


terça-feira, 1 de abril de 2014

C++ - Opening a windows with the man page for the word under the cursor - VIM

How to get help when stay developing in VIM?
Como obter ajuda quando estiver desenvolvendo em VIM?

Put the cursor at the word that you want and click "shift + k", the man page of specific command will open
Coloque o cursor na palavra que deseja e click "shift + k", a página do comando específico irá abri

Is the same that you do in command line:


    man 3 <word>

Section of man page on Unix:


Section
Description
1
General commands
1M
System administration commands and daemons
2
System calls
3
C library functions
4
File formats and conventions
5
Miscellanea
6
Games and screensavers
7
Special files (usually devices, those found in /dev) and drivers







Unix Command - How to see library dependencies of programs? - ldd

Viewing library dependencies of programs in Unix with ldd:

command:

     ldd <path_of_binary>


We would see something like this:


 ldd /bin/grep

        linux-vdso.so.1 =>  (0x00007fffad1ff000)
        libpcre.so.0 => /lib64/libpcre.so.0 (0x00000032fe600000)
        libc.so.6 => /lib64/libc.so.6 (0x00000037eaa00000)
        /lib64/ld-linux-x86-64.so.2 (0x00000037ea600000)




The environment var to load the library is LD_LIBRARY_PATH whether some library was not loaded.

terça-feira, 25 de março de 2014

Unix Command - How can you get the subdirectories of an existing directory in *Unix? - find


You can use the find command in *Unix.

Go to the directory that you want to get the subdirectories and do this command:

 find . -type d 


Types:
   d - directory
   f - file
   l - symbolic link


----------------------

other way:

In the directory that you want, do this command:

 ls -ltr | grep ^d 

*this command does not get all existing subdirectories.

terça-feira, 18 de março de 2014

Oracle - How to copy a table to another server?

You can copy a table to another server/database, in Oracle, using this command:

Sqlplus:
 SQL> COPY FROM username1/password1@tnsname1 
           TO username2/password2@tnsname2
      INSERT table_name (*) USING (SELECT * FROM table_name); 


Other way is using dump file in Unix:

Export:
 exp username/password@tnsname FILE=filename.dmp \
    TABLES=owner.table_name COMPRESS=y  


Import:
 impdp username/password dumpfile=filename.dmp