Mac OS X VirtualBox and Shared Folders

Posted on August 5, 2008
Filed Under mac os x | Leave a Comment

I use eclipse to play around with some ruby/php/jsp code. And usually that’s ~/Projects/workspace/my_site

Now, let’s assume that I would like to host these files off my Ubuntu guest OS… What do I do?
1. Add the folder in “Shared Folders” screen as seen on the screenshot.
2. Boot the guest OS up and run this command:

root@virtuozo~$ mount -t vboxsf -o uid=1000,gid=33 blog /var/www/blog/

As you can see, I used exactly the same name that’s set in the

screenshot above. What’s next? Just restart apache and point your browser to the right IP/hostname. In the example above, uid=1000 is normal user, whereas gid=33 is the www-data user (apache).
PS: You might need to do some port forwarding, so that when you point your browser to http://localhost:8000 it will be forwarded to localhost:80 on your guest OS.

VirtualBox on Mac OS X and port forwarding

Posted on August 5, 2008
Filed Under mac os x | Leave a Comment

I’ve been using VirtualBox for some time already, and frankly speaking I’ve got no problems.

VBoxManage setextradata “ubuntu-lts” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestweb/Protocol” TCP
VBoxManage setextradata “ubuntu-lts” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestweb/GuestPort” 80
VBoxManage setextradata “ubuntu-lts” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestweb/HostPort” 8000

VBoxManage setextradata “ubuntu-lts” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssl/Protocol” TCP

VBoxManage setextradata “ubuntu-lts” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssl/GuestPort” 443
VBoxManage setextradata “ubuntu-lts” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssl/HostPort” 8443

VBoxManage setextradata “ubuntu-lts” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol” TCP

VBoxManage setextradata “ubuntu-lts” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort” 22
VBoxManage setextradata “ubuntu-lts” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort” 2200

VBoxManage setextradata “xp_pro” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestremote/Protocol” TCP

VBoxManage setextradata “xp_pro” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestremote/GuestPort” 3389
VBoxManage setextradata “xp_pro” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestremote/HostPort” 3388

Now, let’s say you want to remove any of the above port forwardings (I’ll do for SSL port forwarding in my case):

VBoxManage setextradata “ubuntu-lts” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssl/Protocol”

VBoxManage setextradata “ubuntu-lts” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssl/GuestPort”

VBoxManage setextradata “ubuntu-lts” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssl/HostPort”

Basically, you just remove the last string from the same set of commands.

How to brute-force password protected zip file?

Posted on November 9, 2007
Filed Under bash, linux, mac os x | Leave a Comment

Imagine a situation when you need to unzip a password protected zip file. So, how do we do it? 

synack@deimos $ cat crack.sh
#!/bin/bash
# Author: K. Jusupov
# Date: 09/11/2007
# Description: Brute force the password protected zip file using ‘password’ from a file

while read line; do
unzip -P $line $1;
if [ $? = 0 ]; then
# successful unzip
clear
echo “Password found: $line”
break
fi
done < passwd.txt

Leopard upgrade

Posted on November 4, 2007
Filed Under mac os x | Leave a Comment

Well, it was 26th when I went to our local (read nearest) Mac shop, I knew that I’m not gonna be purchasing Leopard, it was more of to see what is gonna happen… Basically, when I reach the shop, the doors were half closed, and some sort of crowd was outside.

Next day onwards I’ve read different post talking about the experience the users were having installing, configuring, customizing or upgrading, etc… There were people who had that experience in a bit salty way…

So, today I eventually got my copy of Leopard and after getting all my backups done, started upgrade… To be on the safe side, I did verify and repair my hard disk, just in case my upgrade will fail. It took about 1.5 - 2 hours to finish the upgrade and get my very first experience with Leopard :)

I got my mail (about 500mb) without any issues, all my pictures (about 20gb) without any problems. I think all my apps are OK, working fine… I don’t think I will be able to do any benchmarks on the performance, speed, etc… As never had problems running on my 2gb RAM and 2.16 Ghz Core 2 Duo MacBook. So, overall I can say - my upgrade went very smooth, no issues. Right after the upgrade finished, was able to get on-line (wi-fi) and get some software updates.

Hopefully next few posts will be able new features, new apps, etc…

Read/write activity on tables - PostgreSQL

Posted on November 3, 2007
Filed Under PostgreSQL | Leave a Comment

If you ever wanted to know which tables are actively being hit on your database, please pay attention to: http://www.postgresql.org/docs/8.1/static/monitoring-stats.html

postgres@server:~$ psql testdb  -c “select relname, idx_tup_fetch as seeks, n_tup_ins + n_tup_upd + n_tup_del as writes from pg_stat_user_tables order by writes desc limit 5;”
relname        |  seeks   | writes
——————+———+——–
user                    |  364963 | 355314
employee          |     232     | 282747
class                   |  587978 | 190938
task                    |      79      | 125255
project               |                | 117282
(5 rows)

Based on these kind of output you might want to reconsider some… Maybe reconsider how your database is setup? Put most active tables as a separate database? Move them to a separate discs? etc…

How big is PostgreSQL database size?

Posted on November 1, 2007
Filed Under PostgreSQL | Leave a Comment

Today found another very useful info from http://www.planetpostgresql.org/

tempdb=# SELECT pg_database.datname,
pg_size_pretty(pg_database_size(pg_database.datname)) AS size
FROM pg_database;

And this is what it shows:

     datname      |  size
——————+———
postgres         | 3480 kB
jasperserver  | 82 MB
testdb             | 3480 kB
template1      | 3537 kB
template0     | 3480 kB
tempdb          | 127 MB
(6 rows)

Time: 143.405 ms

xfce4 + kiosk mode

Posted on October 8, 2007
Filed Under linux | Leave a Comment

Additional to my previous post where I’ve mentioned about LTSP setup and xfce4, I’d like to post a little about how we’ve setup xfce4.

Following this info (http://wiki.xfce.org/kiosk_mode), we’ve setup xfce4 in “kiosk” mode, which means standard xfce4-panel through-out the system for all non-wheel users.

root@server~# cat /etc/xdg/xfce4/kiosk/kioskrc
[xfce4-panel]
CustomizePanel=%powerusers,foo

[xfce4-session]
CustomizeSplash=ALL
CustomizeChooser=ALL
CustomizeLogout=ALL
CustomizeCompatibility=%wheel
Shutdown=%wheel
CustomizeSecurity=NONE

Now, only those users in “wheel” group can customize their xfce4-panel items, the rest of the users will get the standard configuration files from /etc/xdg/xfce4/panel/*

First we had some problems trying to get this standards to work, i don’t know why, but we could not grasp the idea of “kiosk” mode, and were trying to add customized configuration files into $HOME/.config/xfce4/panel/* and were wandering why our custom panel is not there on login…

Later we understood that by creating “kioskrc” file, we’ve forced the xfce4 not to read $HOME/.config/xfce4/panel/* but read /etc/xdg/xfce4/panel/*

Eventually (today) we’ve all that to behave as we wished. You can see below how all that will/should look like:


synack@xcpmd /etc/xdg/xfce4/panel $ ls
actions-12.rc launcher-9.rc separator-6.rc
launcher-10.rc orageclock-11918073222.rc systray-4.rc
launcher-11918071840.rc panels.xml tasklist-3.rc
launcher-11918072271.rc separator-11915433711.rc xfce4-menu-5.rc
launcher-7.rc separator-11918074303.rc
launcher-8.rc separator-13.rc

How to install LTSP-4.2 on Gentoo

Posted on October 1, 2007
Filed Under linux | Leave a Comment

Well, as an introduction I’d like to say that we’re using Linux & quite a bit of Open Source stuff through-out of organization. Stuff like: Linux, PostgreSQL, firefox, thunderbird, claws-mail, openoffice and LTSP.

This post is about LTSP. I’m really amazed at the quality of LTSP development. It’s quite easy to install and configure to fit one’s needs. For example, we’ve decided to use Gentoo Linux as base OS and XFCE environment for to get most out of the hardware at our hands.

Another thing that I must say - Gentoo wiki and documentation project is one of the best sources for technical how-tos, etc.

  1. Gentoo Linux Handbook: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml
  2. XFCE Configuration Guide: http://www.gentoo.org/doc/en/xfce-config.xml
  3. Gentoo - LTSP Guide: http://www.gentoo.org/doc/en/ltsp.xml

I’ve just followed the above given sequence and got running LTSP setup in about 6-7 hours. Thin-clients were able to login, having required application up and running: samba, cups, openoffice, firefox, claws-mail, gftp, xpdf.

Our servers have: AMD Opteron(tm) Processor 242, 3GB RAM, and SATA HDDs, serving about 15-20 simultaneous users each, with an uptime of months, and reasonable performance.

PostgreSQL, copy from a file as non-superuser

Posted on September 29, 2007
Filed Under PostgreSQL, bash | Leave a Comment

testdb=> COPY weather FROM ‘/tmp/input_data.txt’;
ERROR: must be superuser to COPY to or from a file
HINT: Anyone can COPY to stdout or from stdin. psql’s \copy command also works for anyone.

So, how do we copy?

there is more than a way to skin a cat…

CREATE TABLE table1 (
code char(5),
name char(10)
);

synack@deimos db $ cat /tmp/input_data.txt
1,kamchi
2,mahabat
3,kamila

postgres@deimos ~ $ cat /tmp/input_data.txt | psql -h localhost -d testdb -c “copy
table1 from stdin delimiter ‘,’;”

postgres@deimos ~ $ psql -d testdb -c “select * from table1;”
code | name
——-+————
1 | kamchi
2 | mahabat
3 | kamila
(3 rows)

WordPressDash - Dashboard widget to post to wordpress

Posted on September 8, 2007
Filed Under mac os x | Leave a Comment

I’m using WordPressDash, which is a Dashboard widget to get this post posted on my WP :)

keep looking »