Tuesday, September 5, 2017

The Power of VIM


h   move one character left
j   move one row down
k   move one row up
l   move one character right
w   move to beginning of next word
b   move to previous beginning of word
e   move to end of word
W   move to beginning of next word after a whitespace
B   move to beginning of previous word before a whitespace
E   move to end of word before a whitespace


0   move to beginning of line
$   move to end of line
_   move to first non-blank character of the line
g_  move to last non-blank character of the line

gg  move to first line
G   move to last line
ngg move to n'th line of file (n is a number; 12G moves to line 12)
nG  move to n'th line of file (n is a number; 12G moves to line 12)
H move to top of screen M move to middle of screen L move to bottom of screen
zz scroll the line with the cursor to the center of the screen zt scroll the line with the cursor to the top zb scroll the line with the cursor to the bottom
Ctrl-D move half-page down Ctrl-U move half-page up Ctrl-B page up Ctrl-F page down Ctrl-O jump to last (older) cursor position Ctrl-I jump to next cursor position (after Ctrl-O) Ctrl-Y move view pane up Ctrl-E move view pane down
n next matching search pattern N previous matching search pattern
  • next whole word under cursor
  1. previous whole word under cursor
g* next matching search (not whole word) pattern under cursor
gd  go to definition/first occurrence of the word under cursor
g#  previous matching search (not whole word) pattern under cursor
%   jump to matching bracket { } [ ] ( )

fX  to next 'X' after cursor, in the same line (X is any character)
FX  to previous 'X' before cursor (f and F put the cursor on X)
tX  til next 'X' (similar to above, but cursor is before X)
TX  til previous 'X'
;   repeat above, in same direction
,   repeat above, in reverse direction



References:
http://vim.wikia.com/wiki/All_the_right_moves


Morning headache with Postgresql

While I'm doing python exercise. Suddenly, my database connection was down for no reason. It takes me 2 hours to fix the issue and I almost gave up. Damn it! actually, I didn't say that until now. haha

But I learn new stuff today especially postgres commands, like:

To check the database server status

/etc/init.d/postgresql status


As usual, my friend google help me find out the solution and took me a while to find it. Here's the link https://askubuntu.com/questions/50621/cannot-connect-to-postgresql-on-port-5432




First purge the old postgres install.

sudo apt-get remove --purge postgresql-9.3

Now simply reinstall

sudo apt-get install postgresql-9.3




Now, when I run my odoo. My username "devlynard" was not found it is because I reinstall the postgres. So, I just add it back. 




Eureka!





Python Rocks!

I have a transfer knowledge today with my colleague as he will be leaving soon. While listening to him I look at his code on how to write the INI file in python. I was wondering how he did it. I know in Java before and I can't really remember the code. So to make it short, I google it and try to learn by my self.

I found this site and it's really straight forward.
https://martin-thoma.com/configuration-files-in-python/

you can create a variety not only INI file but also JSON,YAML and XML. wow, that's great!

It's all about VIM

Move the cursor from the two (vertical) split window in Vim.

By holding the the Ctrl, press w two times do the magic.


Ctrl-w w or type :wincmd w to move the cursor between the two windows/buffers.


Eureka!

References:
https://stackoverflow.com/questions/6071266/how-to-flip-windows-in-vim

Monday, September 4, 2017

Change File Permission in Linux

I have encountered this issue when I tried to edit the file postgresql.conf and pg_hba.conf. Both are with read-only permission. So I was digging on the internet and finally found a solution.

chmod 066

The syntax:
$chmod 066 filename

$chmod 066 postgresql.conf

Eureka!


References:
http://www.filepermissions.com/directory-permission/066

Tuesday, July 11, 2017

MongoDB installation

This is my first post as using the mongodb. First, I just downloaded the installer file from mongodb site. There are some points to remember if you install mongodb for the first time.

create c:\mongodb folder
- this is to be used for the custom installation

create \data\db folder
- put under the mongodb folder, use for database data file

create \logs
- for the mongodb log file

open powershell by run by administrator access and execute below command
>.\mongod.exe --directoryperdb --dbpath c:\mongodb\data\db --logpath c:\mongodb\logs\mongo.log --logappend --rest --install

start the mongodb service
>net start MongoDB



> show dbs
admin  0.000GB
local  0.000GB
> use mycustomers
switched to db mycustomers
> db
mycustomers
> show dbs
admin  0.000GB
local  0.000GB
> db
mycustomers
>   db.createUser({
...     user:"brad",
...     pwd:"1234",
...     roles: ["readWrite", "dbAdmin"]
... });
Successfully added user: { "user" : "brad", "roles" : [ "readWrite", "dbAdmin" ] }
> db.createCollection('customers');
{ "ok" : 1 }
> show collections
customers
> db.customers.insert({first_name:"John", last_game:"Doe"});
WriteResult({ "nInserted" : 1 })
> db.customers.find();
{ "_id" : ObjectId("5965cba0a07b84a6ed70301a"), "first_name" : "John", "last_game" : "Doe" }

free online comma separating tool

https://delim.co/#