David Thomas Baker » Linux

Easy - Convert WMA into an MP3

From a linux command prompt, do the following:

MyWmaFile.wma is the file you want to convert into an MP3 called MyMP3File.mp3

first rip the wma into a wav file like so:

$ mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader MyWmaFile.wma && lame -m s -V 3 audiodump.wav -o MyMP3File.mp3

doneskies.

Posted by David Baker in: Linux | Tags:
Some ads...

Setting up Raid 1 on Linux

Here's the process for when I forget next time:

Create new linux partitions to be used in the software raid array, use mdadm to set them up, wait for them to sync, then create the filesystem on the new md0

# fdisk /dev/hdX 
# mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/hdX1 /dev/hdY1
# watch cat /proc/mdstat (takes 30 mins for 80GB)
# add ARRAY /dev/md0 devices=/dev/hdc1,/dev/hdd1 to /etc/mdadm/mdadm.conf
# reboot
# mkfs.ext3 /dev/md0

/dev/md0 is now ready to be used :)

Posted by David Baker in: Linux | Tags:

OpenMoko Neo Freerunner

Thought I would start blogging about my new openmoko freerunner.. so to start off here's some stats and pics. Continue Reading »
Posted by David Baker in: Linux | Tags:

Gold Coast Java Programmers

Hello search engines.

Any Java Programmers on the Gold Coast please go and sign up to the Gold Coast Java group here:

http://groups.google.com/group/gcjug

from the group: "A community of Java developers based in and around The Gold Coast, Queensland. This is a very informal group at present, we may do some casual meetups - but the purpose of the groups is really for Collaboration, Networking and possible recruitment."

Posted by David Baker in: Linux | Tags:

Hide .svn files on a samba share

Found myself in a situation where I was editing and uploading some files through Dreamweaver on a windows box. The files were accessed via a mounted samba share on a debian server.

Didn't want dreamweaver to see all the .svn directories and files under them (so uploading a folder from dreamweaver would skip uploading the .svn stuff).

Thanks to Gabriel for the easy solution:

[homes]
        veto files = /.svn/

------------
complex solution:

 

On the samba server I set these options under the [file share] section:

   hide unreadable = yes
hide unwriteable files = yes

and restarted samba.

Then make all the .svn folders unreadable by my samba user like this:

# cd /path/to/samba/share
# chown myusername: . -R
# for i in `find . -name .svn  `; do echo "setting $i"; chown -R othername: $i; chmod o-rwx $i; done;

that way all the .svn folders will be owned by othername and not accessible by the samba user myusername, samba will hide this folder from the windows box... 

now I can edit and upload files from dreamweaver whilst commiting svn changes through a terminal at the same time.

Posted by David Baker in: Linux | Tags:

Force www. using .htaccess mod_rewrite

Forcing a redirect to "www." on a website using .htaccess and mod_rewrite is easy.

Create a .htaccess file with this in it:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.yourdomain.com$
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301]

If you need to combine this redirect with some other mod_rewrite rules, then try putting the redirect at the very end like so:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [L,QSA]
RewriteCond %{HTTP_HOST} !^www.yourdomain.com$
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301]
Going one step further you can redirect all requests except those for certain files like so:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [L,QSA]
RewriteCond %{HTTP_HOST} !^www.yourdomain.com$
RewriteCond %{REQUEST_FILENAME} !some_script.php
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301]

That way requests to http://yourdomain.com/some_script.php will not be redirected to http://www.yourdomain.com/some_script.php but all other requests will.

 

Posted by David Baker in: Linux | Tags:

svn: PROPFIND request failed on /svn - Moved Permanently

Setup a new svn repo, and got the following error:

# svn checkout http://xx.xx.xx.xx/svn /var/www/myproject --non-interactive
# svn: PROPFIND request failed on '/svn'
# svn: PROPFIND of '/svn': 301 Moved Permanently (http://xx.xx.xx.xx/)

Make sure apache has read/write access to the repo, if that doesn't fix it, then move your svn repo out of the DocumentRoot and you should be set.

 

Posted by David Baker in: Linux | Tags: svn |

suPHP + Plesk + apache vhosts

I installed suPHP on a plesk box, works great for all the client vhost websites, all their PHP scripts run with their respective user account privellages.

However, suPHP was enabled for every PHP script which ran under apache. This caused a few issues ...

Continue Reading »
Posted by David Baker in: PHP | Linux | Tags: plesk |

Geek Interview Questions

Will update this page each time I think of a cool/hard/fun interview question Continue Reading »
Posted by David Baker in: PHP | Linux | Tags: interview questions |

Creating RPMs - Simple RPM Builder Script

Here's a simple script that helps package up RPM's - designed for packaging up php code from a /var/www/html/your_project directory - can be easily modified to suite other needs.

(hmm - I hope stripslashes() hasn't played around with anything too much)

Continue Reading »
Posted by David Baker in: Linux | Tags:

Export Oracle 10g into Oracle XE

I couldn't get the export working through Oracle enterprise manager ... so I did it through a shell.

oraclebox is a solaris box with oracle 10g installed

oraclebox#  export ORACLE_HOME=/u01/app/oracle/oracle/product/10.2.0/db_1   
(set this to ur own oracle home dir)
oraclebox# cd $ORACLE_HOME/bin
oraclebox# ./exp 'username/password@orcl
(follow the prompts - this will create a file called expdat.dmp - copy this
to the Oracle XE server)

xebox is a debian box with oracle xe edition installed

xebox# export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/
xebox# cd $ORACLE_HOME/bin
xebox# ./imp 'username/password@xe'
(follow prompts - enter full path to the expdat.dmp file you copied to this server)

 

Posted by David Baker in: Linux | Tags:

Setting up OpenVPN - debian

Here's the steps involved in getting OpenVPN client up and running.. Continue Reading »
Posted by David Baker in: Linux | Tags: openvpn |

Ubuntu - upgrade to Feisty - Device lookp failed

The error on tty1:

[ 80.143123 ] device-mapper: table: 254:5: linear: dm-linear: Device lookup failed
[ 81.289517 ] device-mapper: table: 254:5: linear: dm-linear: Device lookup failed
etc...

 

Continue Reading »
Posted by David Baker in: Linux | Tags: ubuntu |

PHP Syntax Highlighting in Vi / Vim

Setting up syntax highlighting in Vim is pretty easy. For one off situations - type the following while in vim:

:syntax on

If you would like syntax highlighting to be on all the time put the following in your ~/.vimrc file:

syntax on

Some other useful .vimrc settings:

set background=dark
syntax on
set ai

"set ai" does auto-indentation in vim

Posted by David Baker in: Linux | Tags: vim |

Simple Apache htaccess/htpasswd - Remote Access

Sometimes it is useful to give out htpassword protected access to certain areas of your web server (say if you are developing an app for someone and want to give them a preview). Here is a simple way to do it:

Continue Reading »
Posted by David Baker in: Linux | Tags: apache |

Upgraded Ubuntu - got eth1:avah

Well after upgrading Ubuntu I started seeing

eth1:avah    inet addr:169.254.6.235

when doing an `iwconfig`

It looks like Ubuntu is setting up a dummy IP as an alias to my wireless adapter so that boot times are improved.

Posted by David Baker in: Linux | Tags: ubuntu |

Sending Mail (with attachments) from a Linux shell

Ever need to send a log file or something to an email address:

for text attachments:

mail -s subject email@address.com < /path/to/my/text.file 

for binary attachments (images etc..)

mutt -s subject -a /path/to/image.jpg email@address.com < /dev/null

 

Posted by David Baker in: Linux | Tags:

Oracle Joins Across Multiple Servers

You can create a link as:

CREATE PUBLIC DATABASE LINK "OtherDB" CONNECT TO "UserName" IDENTIFIED by "Password" USING 'SID'

SELECT * FROM "OtherSchema"."TableName"@"OtherDB";

or

CREATE SYNONYM "otherTableName" FOR "OtherSchema"."TableName"@"OtherDB"
SELECT * FROM "otherTableName"

( it's easier to do this via the oracle enterprise manager http://192.168.X.X:1158/em Administration > Schema )


You need to establish the link as a user on the other instance that has read access to the tables you need to join. Then:
SELECT a.columns, ..., b.columns
FROM yourTable a INNER JOIN otherdb.otherTable ON a.column = b.column
WHERE ...
ORDER BY ...;

After the link is establiched, you can treat it as one of your tables in the selects, just append the link name to the front of the table name.

Posted by David Baker in: Linux | Tags: oracle |

How to tell if Apache2 is running in MPM - Prefork

Apache2 needs to be running in pre-fork mode for certain things like persistant database connections to work correctly

# /usr/local/apache2/bin/httpd -V|grep MPM
Server MPM: Prefork


Posted by David Baker in: Linux | Tags: apache |

Creating RPMs - Distributing PHP Code

Distributing PHP code with RPM's

Continue Reading »
Posted by David Baker in: PHP | Linux | Tags: rpm |

Website Screenshot Thumbnail Creator Script

One day I needed to create thumbnails of about 300 websites, this would usually take a very long time, so I wacked together a simple shell script which makes use of Firefox, Xvfb, and Imagemagick

The script creates a virtual X desktop, starts a Firefox instance, and then, using the openUrl command, proceeds to load each website and capture a screenshot one at a time.

If you cannot get Xvfb working, you should be able to run this with little modification on a spare linux desktop. I suggest you play with image magicks cropping tools to remove the firefox decal.

here is the original bash script: Continue Reading »
Posted by David Baker in: Linux | Web | Tags:

/usr/bin/dpkg received a segmentation fault.

E: Sub-process /usr/bin/dpkg received a segmentation fault.

Try:

dpkg --clear-avail
apt-get update

Otherwise try a reboot - this happened to me after a virtual server ran out of ram. Reboot fixed it.

Posted by David Baker in: Linux | Tags: debian |

Setting up XEN

Install debian on physical server using cd.

Install xen compatible kernel:
# apt-cache search kernel|grep xen

reboot into xen kernel

install xen tools

follow this tutorial http://www.howtoforge.com/perfect_setup_xen3_debian

when bootstrapping a debian box if you chroot and base-config returns Terminated
sh-2.05b# mount -t proc proc /proc
sh-2.05b# cd /dev
sh-2.05b# ./MAKEDEV generic
sh-2.05b# mount -t devpts -o gid=5,mode=620 none /dev/pts
sh-2.05b# base-config
should work now

also followed this http://www.debian-administration.org/articles/533


virt-install -n vm04.img -r 400 -f /home/xen/domains/vm04.img -s 2 --nonsparse -w bridge:xenbr0 --os-type=linux -p -l http://192.168.0.21/rhel5/disk1 --nographics



Posted by David Baker in: Linux | Tags: xen |

Apache mod_rewrite - Melbourne IT - PHP-CGI

Ran into a problem trying to use mod_rewrite in .htaccess on a Melbourne IT hosting account.

They seem to run PHP as CGI instead of an Apache module. Read the differences here: http://blog.dreamhosters.com/kbase/index.cgi?area=2933

Here's the rewrite script that worked in the end:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [L,QSA]

The problem was a missing / before the index.php

Posted by David Baker in: PHP | Linux | Web | Tags: apache | mod_rewrite |

Apache2 Sub Domains

Sub domains in Apache... Continue Reading »
Posted by David Baker in: Linux | Web | Tags: apache2 |

SSH Tunneling Fun

# ssh -p 220 -L 8080:192.168.0.254:80 user@remote.host

woo!

Posted by David Baker in: Linux | Tags: ssh |

Useful Bash Shortcuts

Here's some simple bash shortcuts that make using a Linux shell so much easier...

Ctrl + R etc..

Posted by David Baker in: Linux | Tags:

NoMoreHoons

Posted by David Baker in: Linux | Ideas | Tags:

Software RAID - Rebuilding causes machine to lag

# cat /proc/mdstat

how to change resync speed so system is usable

Continue Reading »
Posted by David Baker in: Linux | Tags:

Using SCREEN - Truley interactive login shell

Here's a simple way to view and even interact with a linux user who logs into your machine

Using the `screen` tool we automatically connect the user upon login to a `screen` instance, which we can then join and control.

I believe there is a bsd tool that provides this feature out of the box?

in /etc/passwd put...

Posted by David Baker in: Linux | Tags: screen | spying |

Bluetooth + Mobile + Linux

It was hard to find .. Continue Reading »
Posted by David Baker in: Linux | Tags: bluetooth | mobile |

Apache displaying ? characters

set the default charset in /etc/apache2/apache2.conf to:
AddDefaultCharset ISO-8859-1
Posted by David Baker in: Linux | Tags:

Internal/External Trusted/Untrusted Bind9

Ever wanted to provide different dns responses depending on where the request came from?

For example, a query for mywebsite.com coming from the local network 192.168.0.0/24 will respond with 192.168.0.254, however a query for mywebsite.com coming from the internet address 1.2.3.4 will respond with 4.3.2.1

Here's a simple way to do it using a single bind instance.

config coming soon

Posted by David Baker in: Linux | Tags:

Sharing is Caring - Single Keyboard Between Multiple Computers

Synergy

http://synergy2.sourceforge.net/

my config examples coming soon

Posted by David Baker in: Linux | Tags:

Search My Site

Featured Projects

Collector Comics is THE place to buy, sell, and research comics online. Launching soon.
Launch » Screenshot »
Webitor is a kick-ass easy to use, easy to extend, non-database driven Content Management System. Version 2 with reseller plan coming soon.
Launch » Version 1 »
GC Lounge is my own pet social network and test bed for social related code. Made by locals for locals.
Launch »
GG has indexed over half a million recent Trade Mark applications. This revolutionary tool is extremely valuable for industry experts.
Launch »
GCWiFi is the hub for techies interested in joining a ad-hoc wireless mesh spread across the Gold Coast
Launch »
Web based financial client management system
Launch »
OS Commerce modules and template modification
Launch »
View More Projects »

Daves Friends

BlueTeddy
WebSpark
GC Designer Forum
IPWealth Trademarks
Cheap Websites
Bonsai Shop
Webitor CMS Resellers
Hayley Crook
David Novakovic
Ben Novakovic
Richard Morwood
Gold Coast Linux
Aussie Click
CMS Website Design
Inspire Tuition
Gold Coast Music Network and Gold Coast Gig Guide

Chat with Dave

Powered by...

In the works

Webitor - Easy to use Content Management System with Shop, Newsletter, and Reseller plan