Building Linux From Scratch with Ubuntu 9.10 – Part 1

Before anything else

Building Linux from vacuum is a very hard, dangerous and satisfactory process. Four things can happen to you:

1) You end up accidentally deleting data from your hard disk

2) You end up with a useless pile of non-working binaries and source code sitting in your disk

3) You give up and call mom

4) And on very rare cases you end up with a barely working spartan linux setup to show to your friends that you won that war

It is up to you to make sure only step 4 happens. It will only depend on whats inside your skull.

Read more…

Howto: NetBeans + Java + OpenGL (JOGL) + 3d Graphics Demo

This is a quick howto install NetBeans and needed plugins to start creating 3D java programs, including games in.  Tested on Ubuntu 9.04 Jaunty. Read more…

Buffer IO error while booting Ubuntu from pendrive?

I’m in a hurry so this will be quick:
Try disabling floppy drive in BIOS config.

Free unused RAM memory in linux

I needed to free some garbage in my ram due to my bad coded OpenGL experiments and their memory leaks. So I found this technique which freed about 1.2GB of my RAM:

# Generate a 2000MB file
dd if=/dev/zero of=junk bs=10MB count=200
# by now top will show not much free memory left.
 rm junk

Find files by name and text inside them in Linux

find /var/www -iname '*.php' | xargs grep 'print_r' -sl

/var/www/blog/www/wp-admin/includes/upgrade.php
/var/www/blog/www/wp-admin/install-helper.php
/var/www/blog/www/wp-admin/user-edit.php
/var/www/blog/www/wp-admin/import/blogger.php
/var/www/blog/www/wp-app.php
/var/www/blog/www/wp-content/themes/default/functions.php
/var/www/blog/www/wp-includes/cache.php
/var/www/blog/www/wp-includes/atomlib.php

The command above:

  • searches in /var/www
  • for files with .php extension
  • for files that contain the “print_r” string

Taken from: http://www.liamdelahunty.com/tips/linux_find_string_files.php

PHP Session name. Or how to separate sessions from different sites on the same server

Recently I had to work on an environment that had many sites hosted on the same machine.

For my shock they all the websites where using the same PHP session name! That alone was the main source of conflicts, bugs and HUGE unbelievable security holes. Imagine logging in one site and appear as logged also on another but as a different user? Imagine chaos.

Fortunately the fix is easy if you know what you are doing. I just had to name PHP sessions for each site. Here are two simple methods:

1) call session_name() in beginning of every page

session_name('My_Site_Name');
session_start();

2) .htaccess file in site root directory containing:

php_value session.name My_Site_Name

Have a nice day.

Using gedit for programming

I’ve been using gedit (now at v2.26.1) for coding.

It handles web developing quite well, supports openning samba shares (for windows shares) and has syntax highlighting for many languages. I use it mostly for PHP, CSS, HTML and JavaScript.

My past editor was the also FOSS, Komodo Edit, which is great and I recommend. Some features I miss from Komodo Edit in gedit are:

  • Change file encoding in statusbar/save dialog.
  • Search/Replace scope: Current document / Selected Text / Open files
  • Tab navigation with CTRL+TAB and CTRL+SHIFT+TAB (gedit uses CTRL+ALT+PGDWN/PGUP)
  • Ability to cut entire current line (including new line chars) when I hold CTRL+X with no selected text
  • Not per file search settings. If search/replace dialog can search in all files, and if it remembers keywords that where searched across opened files, why do I need per file search settings such as the “Match case”, “Match entire word only”, “Search backwards” and “Warp around”? I’ll never remember what is the search setting I’m using when searching file X or Y. But I might remember them if they are the same when I go search in other file and they are the same as my last search.

I might implement those features as gedit plugins (and release them here) when I get some time to.

Back to Ubuntu

Arch is great. But I just don’t have that extra spare time to get the tids and bits to work.

I’m going back to Ubuntu 9 which just works (at least for me).

Like I said in past post, differente distros, different pourposes.

Pastebin/Nopaste from console

Pastebin, aka Nopaste, is a very useful tool for sharing text, code and debugging information. You post the text string and it gives you a tiny url that can be seen by anybody in the internet.

Being able to share text files from console can be very useful at times.

For Arch linux, there is a ruby script in AUR that does that:

sudo yaourt -S nopaste

Usage:

nopaste /path/to/text_file

Output:

http://rafb.net/p/pzBBNQ21.html

Compare 2 directories in linux

diff /path/to/dir /path/to/dir2 | sort

Only in /path/to/dir: 276867main_08pd2733_full.jpg
Only in /path/to/dir: Got 7 Kart.jpg
Only in /path/to/dir2: NewFolder
Only in /path/to/dir2: newFile
Only in /path/to/dir2: prisonstudies-org.jpg