Saturday, 18 October 2014

Linux sucks: Xubuntu 14.04 on Asus G55VW

I would like to install Xubuntu to my notebook (G55VW). The most of things works fine, except FN-keys (FN-F4...FN-F6, yeah the LCD&keyboard brightness controls). I read many forums but most of way didn't get solution. I tried most of and here is my version:

1. get and install
https://github.com/guillaumezin/nvidiabl

Install:
sudo make  dkms-install

To remove:
sudo make dkms-remove
2. Update grub
vim /etc/defaults/grub
add "acpi_backlight=vendor" to cmdline
sudo update-grub2 && sudo reboot

3. reboot
Set brightness to the half of max.br:
echo -n 50 | sudo tee /sys/class/backlight/nvidia_backlight/brightness

4. Disable using of the profiles in nvidia-settings.


I had issue with Wireless:
sudo vim /etc/modprobe.d/iwlwifi.conf
options iwlwifi 11n_disable=1 

Saturday, 6 September 2014

Block web-sites with BIND9

I'm skipping the installation and set up of the BIND9 because there are several other site that do it. I just explain how to configure named.conf to be able to block domains.

You'll need a 'null.zone.file' under etc folder:

; DNS NULL Zone File for host filtering

$TTL 36000
@ in  soa  localhost. postmaster.localhost. (
           0   ;serial
           0   ;refresh
           0   ;retry
           0   ;expiration
           0 ) ;minimum

; Zone NS records

@          NS localhost.
           A 127.0.0.1
*          IN A 0.0.0.0


Now see the named.conf:

options {
    directory "c:\bind9\etc";

    listen-on  { 127.0.0.1; };
    forwarders { 192.168.100.1;};
    #forwarders { 8.8.8.8; 8.8.4.4;};#if you would like to use Google DNS servers
    recursion yes;
    allow-transfer { none; };
};

logging{
    channel my_log{
        file "myconf.log" versions 3 size 2m;
        severity info;
        print-time yes;
        print-severity yes;
        print-category yes;
    };
    category default{
        my_log;
    };
};


key "rndc-key" {
    algorithm hmac-md5;
    secret "your secret key";
};

controls {
    #inet 127.0.0.1 port 953
    #allow { 127.0.0.1; } keys { "rndc-key"; };
    inet 127.0.0.1 allow { localhost; } keys { "rndc-key"; };
 };


zone "gemius.pl" {type master; notify no; file "null.zone.file";};
zone "adserver.yahoo.com" {type master; notify no; file "null.zone.file";};

Now the above website will be blocked and you experience a little more responsibility on web-sites.
Of course you can block unwanted web-sites.

Monday, 1 September 2014

TotalCmd Add new custom command

Hotkeys:
SHIFT+F4   create new file

I usually open GitBash. I made a hotkey combination to access faster:
Each config file located under c:\Users\YOURNAME\AppData\Roaming\GHISLER.

WINCMD.INI:

[Shortcuts]
CA+C=em_gitbash
CA+V=cm_ExecuteDOS

usercmd.ini:

[em_gitbash]
button=C:\Windows\System32\WScript.exe,2
cmd="C:\Program Files (x86)\Git\Git Bash.vbs"
path=C:\Windows\System32\

The path is set a location. Remove it if you would like to use at TCM's current folder.

Saturday, 30 August 2014

Zyxel NSA325v2

If you met the following annoying message when you try to start htop on Zyxel NSA325v2:

Error opening terminal: xterm.

Here the quick fix:

export TERM="xterm"
export TERMINFO="/ffp/share/terminfo"

Monday, 28 July 2014

Useful commands

To create a patch:
$ diff -rupN orig new > diff.patch

To execute an '.sh' file under Git Bash:
cmd //c "cica.cmd arg1 arg2"

To change file mode bits in git:
$ git update-index --chmod +x cica.txt

Shell programming (Posix)

I had learn some shell programming basis. I summarized the things to here. I suggest you always try to follow the posix (easier to understand and you can avoid specific shell issues).

Rules (I continuously will update it):

  1. Do not use pushd/popd! Use 'cd -'.
  2. Do not use double equal to compare. This is not c++. Use just one ('=').
  3. Do not use double bracket [[ $foo ]]. Use single bracket ('[ $foo ]').
Difference '$foo' and "$foo":
$export foo=cica
$echo "$foo"
cica
$echo "$foo"
$foo
There is substitution at first case while the other one there wasn't.

Shell script usually started with shebang (or hashbang):
#!/bin/sh

Debug features in shell:
set -euxv

e : stop first error
u : check uninitialized variables / prevent undefined behavior
x : print line the executed command
v : print line as read from input

In posix the return values always a positive numbers (0-255).

Friday, 25 July 2014

Useful/basic key combos in Vim:

:map <F7> : tabn<CR>
:map <F8> : tabp<CR>
:set numbers
:set mouse=a
:set smartindent
:set tabstop=4
:set shiftwidth=4
:set expandtab
:e open file

:set noexpandtab    " Use tabs, not spaces
:%retab!            " Retabulate the whole file

caw: delete current word and go into insert mode
daw: delete current word
e: go to end of current word
gg <X>: goto line <X>
G <X>: goto line <X>

% select single bracket

yy to copy the line
dd to delete the line
v enter visual mode
y yunk/copy
d delete
  p paste after curren line
  P paste before current line

yiw: Yank inner word (the word under the cursor). This command also moves the cursor to the beginning of the word.
viwp: Select inner word and paste with clipboard content
b:go to beginning of current word
yw: yank word
vey: visual mode & end word & yank
vex: visual mode & end word & delete
byw: begin & yank & word

Generate tags file to OmniComplete:
ctags -R --sort=1 --languages=C,C++ --c++-kinds=+p --fields=+iasS --extra=+q

Start vim:
vim -t tags

Type in insert  mode:
<C-n> <C-p>

Navigate in Vim:

Keyboard command
Action
Ctrl-]
Jump to the tag underneath the cursor
:ts <tag> <RET>
Search for a particular tag
:tn
Go to the next definition for the last tag
:tp
Go to the previous definition for the last tag
:ts
List all of the definitions of the last tag
Ctrl-t
Jump back up in the tag stack

Sunday, 20 July 2014

My first post - introduction

Ha minden jól megy, akkor ezen a blogon szándékozom megosztani az agymenéseimet/tapasztalataimat... Elsősorban anyanyelvemen, de szándékaim közt van, hogy angol nyelven is írok bejegyzéseket. Nem tudom minek köszönhetően vágok bele, de lehet a kinti 34-35 celsius fokos idő se tett jót. A téma többnyire szakmai: programozás/informatika. De előfordulhat, hogy más ebbe a témakörbe nem illő dolgokról is fogok írni.
A címről, csak annyit, hogy minden népszerű cím foglalt, így hát ki kellet találnom valami okosat és ez lett.

No magamról pár szót:
Lassan 5.dik éve programozok főállásban egy budapesti irodában. Amikor jelentkeztem, akkor simán "c++" programozót keresett a cég, amire jelentkeztem. A felvételi feladatom, OpenGL alkalmazás volt, egy jelenet shadow mapping techinka használatával. Egészen nehezen ment, rengetegett kellett tanulnom hozzá, hogy teljesiteni tudjam a feladatott. Aztán jött egy hívás, hogy ha érdekel a munka, akkor betölthetem. Hát én örültem, mivel, 3 helyre küldtem, csak CV-t. Folytatás később...