RSS
 

Ubuntu on Asus N53S(V)

08 Oct

To install Ubuntu with a working NVIDIA card on this laptop. Follow these instructions:

  1. Follow https://help.ubuntu.com/community/Asus_N53
  2. Add this to your modules blacklist in /etc/modprobe.d/blacklist.conf:
    blacklist nouveau
    blacklist fbcon
    blacklist vga16fb
  3. Run 3D Graphics intensive applications like Google Earth with
    optirun google-earth
  4. Optional: Mount Windows NTFS partition in /etc/fstab:
    /dev/sda5       /d      ntfs    noexec,nosuid   0       0

Edit: You might not need to add the blacklist. I’ve just setup 11.04 64 bit and did not black list the drivers and it works! Remember to NOT enable the additional drivers in this setup because it will override your Intel Drivers, which are good because you can still run 3D apps but with less power consumption.

 
 

My bash settings

09 Sep
export PATH=$PATH:"/cygdrive/c/Program Files/Vim/vim73"
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'
 
    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi
 
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
 
No Comments

Posted in Settings

 

My VIM Settings

07 Sep
set ignorecase
set tabstop=2
set shiftwidth=2
set autoindent
set expandtab
imap <c-space> <c-x><c-o>
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType css set omnifunc=csscomplete#CompleteCSS

http://shang-liang.com/blog/using-vim-as-actionscript-editor/

 
 

How to backup Windows XP/7 partition with Linux (Ubuntu)

23 Aug

To backup any partition of any file system type with Linux, you can simply run the following command:

dd if=<input_partition> of=&<output_file> bs=<byte_count>

where

<input_partition>:= is the partition you want to backup (this can also be a file if you want to do the reverse). So, e.g. /dev/sda1 for the first partition on the first drive (hence a=drive 1, 1=partition 1, b=drive 2, …).

<output_file> := is the file you want to write the partition to (this can also be the output partition on restore).

<byte_count> := is the size of your file system’s clusters, normally 4096.

dd if=/dev/sda2 of=/d/sda2_partition bs=4096 #for my own reference
tar cvfz sda2_partition.tar.gz sda2_partition # own reference



You can then compress the file using a normal archiver and save a lot of space that way, because dd constructs a file as big as the partition because it reads bit by bit or 4096 bytes multiple times.

 
 

Tim-Hinnerk Heuer Resume

27 Jun

Please view at Tim-Hinnerk Heuer Curriculum Vitae

 
 

Howto: Solving problem with logrotate

25 Dec
/etc/cron.daily/logrotate:
 
error: error running shared postrotate script for /var/log/mysql.log
/var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log
 
run-parts: /etc/cron.daily/logrotate exited with return code 1

Have you been getting this cryptic error message before?

Here is how to get rid of it:

View /etc/mysql/debian.cnf. Look for

user     = debian-sys-maint
password = newpass

Log into mysql as root

mysql -uroot -p
SET PASSWORD FOR `debian-sys-maint`@`localhost` = PASSWORD('newpass');
SET PASSWORD FOR `debian-sys-maint`@`%` = PASSWORD('newpass');
FLUSH PRIVILEGES;

Log out and it should be fixed.

 
No Comments

Posted in Howto, Linux

 

Howto: Install XAMPP 1.7.2 on Windows 7 with XDebug and Netbeans

25 Dec

Hi,

Just for my own reference and some other poor people out there trying to get this to work:

  1. Download XAMPP 1.7.2 from sourceforge.net/projects/xampp/files/XAMPP%20Windows/1.7.2/xampp-win32-1.7.2.exe/download
  2. Install
  3. Download php_xdebug-2.0.5-5.3-vc6.dll from xdebug.org/download.php
  4. Place it in C:\xampp\php\ext
  5. Edit C:\xampp\php\php.ini add:
    zend_extension = “C:\xampp\php\ext\php_xdebug-2.0.5-5.3-vc6.dll”[xdebug]

    xdebug.remote_enable=on

    xdebug.remote_host=127.0.0.1

    xdebug.remote_port=9000

    xdebug.remote_handler=”dbgp”

  6. Enjoy!
 
 

Howto: Postfix aliases setup email account

25 Dec

Edit /etc/postfix/virtual.cf .

vim /etc/postfix/virtual.cf

Add line:

user@example.com localusername

postmap /etc/postfix/virtual.cf

vim /etc/aliases

Add line:

localusername: someother@othersite.com

newaliases

 
No Comments

Posted in Howto, Linux

 

Manawatu Jazz Club Big Band Concert – Christmas Club Day

08 Dec

It’s time for the yearly Christmas concert of the Manawatu Jazz Club Big Band.

It’s on

Sunday 12th December 4:30pm
@ the ANZAC Lounge RSA on Broadway

Featuring

Johnny McCormick
and
The Manawatu Jazz Club Big Band

With
Vocalists
Erna Ferry & Meri Hammi

This is the Annual MJC Big Band Benefit Concert to thank them for their valuable contribution through the year… take some time out from the Christmas rat race and bring lots of friends.

Members $10, non members $15, Secondary School Students $5
Meals & Full Bar Service
~All Welcome~

 
 

Micro-Optimization For High-Level-Language Programmers

01 Oct

In this post I would like to point out some optimizations that seem to be fairly generic. Every average to advanced level programmer should be able to use these little tricks quite effectively. Code that is well written and thought of can be called great code if it takes advantage of every byte available. However, one should also not overdo optimization, because the gain of 1ms cannot make up for half an hour that you spend more on programming it. But if you get used to using these techniques from now on, you should be good. So lets get to it.

Choosing the right algorithm

… is probably the best optimization you can be doing when writing code. Before you think of saving at the register level, think about how efficient the algorithm is that you are using. For example using quick sort for sorting elements is probably a good idea, rather than using slower algorithms like bubble or insertion sort. If you are using a high-level-language (HLL) like PHP, you would probably want to use the internal *sort() functions. They use quick sort on a low level (written in C). For example, suppose you have an array with 1000 variables (which can be objects, primitives or arrays) and you want to sort it by your own sorting order algorithm. Instead of going through great lengths of searching for an implementation of a sort algorithm online or even writing your own, in PHP, for example, you should use the usort() function and be passing in your compare function. Like this you can sort dates, strings or numbers in any order that you like, you just need to define when item A is smaller than item B and return a negative number in that case, and in the converse return a positive number as well as 0 when they are equal. You get the idea. If you find a good algorithm and need to implement it yourself, it might be hard and challenging but it can be well-worth the time spent on it, because you can save the user of your application time and your application server number crunching resources.

Saving on the byte or even bit level

Now to the more generic optimisations that you can think of when you have chosen the right algorithm for your implementation. When you know that the algorithm you are using is good or even could not be better, great. You can go on implementing it. When you do so, you should think of every expression you use more than once as a variable and also reserve the necessary space for it. For example, you could have an expression like (a < b && b < c && b+2 == d). If you use this expression in only one if statement, it is probably a good idea to use the expression as is. As soon as you use the expression more than once, make a variable that describes the purpose of the expression. For example:

aGreaterBAndBLessCAndBPlus2EqualD = a &lt; b &amp;&amp; b &lt; c &amp;&amp; b+2 == a;

Remember that code readability and understanding of it after the initial implementation is more important than saving a few bytes for the variable name. In compiled languages the length of a variable name does not matter usually. Only in higher level, interpreted languages it can make a difference, but again only nano seconds or so. It is still more important to have an efficient algorithm which is easier to achieve when the code is readable, at least when you later come back to it.

Another trick, which actually follows from the above is to optimise loops in a generic way. A simple for loop like:

for (var i = 0; i &lt; somevar.length; i++) {
  // do something with somevar[i]
}

(in JavaScript) can simply be rewritten as

for (var i = -1, leni = somevar.length; ++i &lt; leni;) {
  // do something with somevar[i]
  // THIS SAVES 20% PERFORMANCE FOR EACH LOOP!
}

This only works if you know ahead of time, that somevar.length will not and need not change inside of the loop, which is mostly the case. This runs faster because somevar.length is re-evaluated every time it is called in every iteration of the top-most for-loop. If you give it a temporary variable the CPU can cache the leni variable in a register and check much quicker if i is smaller than that. I read also that ++i can be faster than i++ in some implementations of programming languages such as JavaScript in some browsers. It depends on how the low-level assembly for that is written. I have seen arguments that i++ and ++i have exactly the same amount of machine instructions, but also ++i is not less readable than i++ and it does not hurt to write it that way if it can cut down the number of instructions by one or two in each iteration.

Edit:
You can use the same concepts in C(++). Actually the book “Write Great Code” talks about C and other lower level languages mainly. In C++ it would look like so, if you want to output a string char by char:

char cstring[10] = "My String";
for (int i = -1, leni = strlen(cstring); ++i &lt; leni; ) {
  cout &lt;&lt; cstring[i];
}

Also, if you want to improve your low-level knowlege, even as a high-level programmer like me, it might pay to read the ‘Write Great Code’ series by Randall Hyde. But in essence these tips here should be sufficient for some improvement of your code and should be simple enough to implement for any level programmer. Just remember that the best compiler or interpreter cannot replace a skilled programmer and I think this will stay that way for a long time if not forever. This is also a good thing and will keep us employed.

I hope someone could learn something from this and you think it was worthwhile to read this short article.