Tuesday, October 22, 2013

Building Mysql 5.5 from source

following are the steps I used to build from source and install mysql 5.5 on my debian system

download the Mysql 5.5 tarball from mysql.com . become the root user and move the downloaded tarball to /usr/local/src. unpack the mysql tarball with:
tar -xvzf mysql-5.5.xx.tar.gz

add specific user and group to run mysql as:
groupadd mysql
useradd -r -g mysql mysql 

change directory to be inside source tree
cd /usr/local/src/mysql-5.5.xx

execute make commands
cmake .
make
make install

change to install directory
cd /usr/local/mysql

execute post installation setup commands
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chwon -R mysql data
cp support-files/my-medium.cnf /etc/my.cnf
bin/mysqld_safe --user=mysql &
cp support-files/mysql.server /etc/init.d/mysql.server

login to mysql command line client and set passwords
mysql -u root -p
enter root password when prompted

display existing users
SELECT User, Host, Password FROM mysql.user;

assign password to the root user
UPDATE mysql.user SET Password = PASSWORD('newpassword') 
    WHERE User = 'root';
FLUSH PRIVILEGES;

assign password to the anonymous user
UPDATE mysql.user SET Password = PASSWORD('newpassword')  
    WHERE User = '';
FLUSH PRIVILEGES;

display existing users to verify passwords have been set
SELECT User, Host, Password FROM mysql.user;


exit mysql command line client
quit

add non-root user to mysql group
usermod -a -G mysql myUsername

add symlink to access mysql and mysqladmin
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqladming /usr/bin/mysqladmin



info taken from:
http://dev.mysql.com/doc/refman/5.5/en/installing-source-distribution.html

Friday, October 18, 2013

bash regex to get json value

i needed a bash regex to get the value for a given key in a json file. below is my solution.

json.sh

getJsonValue()
{
    grep -Po '"'"$2"'"\s*:\s*"\K([^"]*)' $1
}

# example usage
# getJsonValue "json_file" "json_key"

 

Building Apache 2 and Php 5 with mysql support from source on Debian

following are the steps I used to build from source and install apache 2.2 and php 5.4 with mysql support on my debian system

i had to install additional packages from using apt:
libxml2-dev
libtool
autoconf


add specific user and group to run apache httpd as:
groupadd www-data
useradd -g www-data www-data 


download the Apache HTTP server from apache.org. become the root user and mv the downloaded tarball to /usr/local/src. unpack the apache tarball with:
tar -xvzf httpd-2_x_NN.tar.gz


download the PHP source from php.net. become the root user and move the downloaded tarball to /usr/local/src. unpack the PHP tarball with:
tar -xvzf php-NN.tar.gz


build and install Apache. reference the Apache install documentation for more details on building Apache.
cd httpd-2_x_NN
./configure --prefix=/usr/local/apache2 --with-included-apr 
    --enable-cgi --enable-cgid --enable-modules=all 
    --enable-mods-shared=all --enable-so 
    --enable-mime-magic --enable-deflate
make
make install


apache 2.2 is available at /usr/local/apache2. to test the installation use the normal procedure for starting the Apache server, e.g.:
/usr/local/apache2/bin/apachectl start
and stop the server to go on with the configuration for PHP:
/usr/local/apache2/bin/apachectl stop


configure and build PHP. configure with Apache 2 and MySQL support.
since apache was built from source, the steps below will match the path for apxs.
cd ../php-NN
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
make
make test
make install

setup your php.ini
cp php.ini-development /usr/local/lib/php.ini
edit your .ini file to set PHP options

verify/edit the apache httpd.conf to load the PHP module. make install from above may have already added this, but check.
LoadModule php5_module modules/libphp5.so


configure Apache to parse certain extensions as PHP. have Apache parse .php files as PHP.
 
    SetHandler application/x-httpd-php
 

to allow .php, .php2, .php3, .php4, .php5, .php6, and .phtml files to be executed as PHP use:

    SetHandler application/x-httpd-php

to allow .phps files to be handled by the php source filter, and displayed as syntax-highlighted source code, use:

    SetHandler application/x-httpd-php-source
 

other apache 2.2 httpd.conf configuration changes that I made:

changed the specific user and group to run httpd as
changed the document root
changed access configuration for different directories
changed errorlog
changed loglevel to debug
changed customlog path
changed scriptalias for cgi-bin
configured access for cgi-bin



use the normal procedure for starting the Apache server, e.g.:

/usr/local/apache2/bin/apachectl start


info taken from:
http://httpd.apache.org/docs/2.2/install.html
http://php.net/manual/en/install.unix.apache2.php

Monday, October 29, 2012

Tiny Fingers Halloween







Tiny Fingers Halloween is a fun game for preschool children. Tiny Fingers Halloween can capture a child's attention and imagination with colorful Halloween icons. Tiny Fingers Halloween allows a preschool child to improve coordination and fine motor skills by changing the colorful icons when touched. Tiny Fingers Halloween also has background music and sound effects.

Tiny Fingers Halloween allows the user to toggle music between on/off, toggle sound effects between on/off, and share with friends. Tiny Fingers Halloween has been released in a free version that is ad supported and a paid version that is ad free.

Some graphics courtesy openclipart.org .

Tiny Fingers


Tiny Fingers is a fun game for preschool children. Tiny Fingers can capture a child's attention and imagination with colorful icons including cartoon animals. Tiny Fingers allows a preschool child to improve coordination and fine motor skills by changing the colorful icons when touched. Tiny Fingers also has background music and sound effects.

Tiny Fingers allows the user to toggle music between on/off, toggle sound effects between on/off, and share with friends. Tiny Fingers has been released in a free version that is ad supported and a paid version that is ad free.

Some graphics courtesy openclipart.org .

Friday, August 3, 2012

'du' command with slimmed down response

Below is a bash script I use to slim down the response from the 'du' command. I've named the script du.sh . Try it out.




#!/bin/bash
if [ $# -lt 1 ] # check command line parameters
then
   echo ""
   echo "usage: `basename $0` param_1"
   echo ""
   echo "parameter: "
   echo "    path to directory"
   echo "     "
   exit 1
else # translate command line parameters to vars
   # define vars
   DIR=$1

  # ensure there is no trailing /
  pathsuffix=$DIR
  [ ${pathsuffix:0:1} != "/" ]
  pathsuffix=${pathsuffix%/}

  # add a trailing slash
  DIR="$pathsuffix"

  # $1 is the directory to use for getting size
  du -h "$DIR" | grep --color=always "$DIR""/[0-9a-zA-Z\-\_\.]\+\$"
fi

Thursday, July 28, 2011

Linux Filesystem Description

Have you ever wondered what the purpose of the directory /opt is? Try typing 'man hier' at a linux command prompt.

Friday, October 15, 2010

Rip audio from flv file

ffmpeg -i /path/to/file.flv -acodec mp3 -ac 2 -ab 128 -vn -y /path/to/file.mp3

Thursday, September 30, 2010

Mount an iso file in linux

mount -o loop /path/to/file.iso /mnt/iso

-o loop: specifies mounting the iso as a loopback device

/path/to/file.iso is the source file

/mnt/iso is the mount point on the filesystem

Make iso in linux

mkisofs -r -o /path/to/file.iso /path/to/directory/

all the files in the /path/to/directory/ will be made into a cd iso image at /path/to/file.iso

-r: preserves long filenames upto 31 characters
-o: output iso image

Thursday, June 10, 2010

fixing cgi newline character problem in vim

I recently had problems with a python "hello world" cgi script. Turns out, I originally wrote the file in a windows system and when I copied the cgi directory to a linux system, I encountered newline issues.

use cat -v /path/to/file.py to print the file to stdout exposing the newline characters.

in vim use

:set fileformat=unix

or

:set fileformat=dos

to write the correct newline characters when saving a cgi file.


Another way to remove the window$ style new line character is to execute the following bash script:
>find /code/cgi-bin/ -type f -iname '*.py' -exec dos2unix {} \;

/code/cgi-bin/ is the path to search
-type f is search for file
-iname is search by name, case insensitive (python files in this example)
-exec is execute the dos2unix program with the results from find being represented by the {}

Hope these tips help.

Wednesday, November 18, 2009

utc date time

to get the utc date and time of the current system enter "date -u" on the command line.

ascii character code

found this little tidbit to help out a friend.

to find the ascii representation of a character in vim, place the cursor over the character and enter ":ascii".

for more info on this vim feature, enter ":help ascii" in vim.


to accomplish the same thing from the command line, "echo" the character and pipe to "od" (read the man page).

Tuesday, September 22, 2009

Burn cd iso to disk

reference: Burning ISO images

### update 2010-10-01 ###

find cd burning device
>wodim --devices

burn iso to device
>cdrecord -v -eject speed=4 dev=/dev/scd0 /path/to/file.iso

###################

find cd burning device
>cdrecord -scanbus
then
>cdrecord -scanbus dev=ATA

burn iso to device
>cdrecord -v -eject speed=4 dev=ATA:0,2,0 /path/to/file.iso

Thursday, August 27, 2009

Vim RegEx Search and Replace

I have the following text:

obj.getHost()
obj.getYourHost()
obj.setHost()
obj.setYourHost()

I want to change getHost() and setHost() to getMyHost() and setMyHost(). However, I do NOT want to change getYourHost() nor setYourHost().

Following is the regex I constructed to make the change:

:1,4s/\.[sg]et\(Your\)\@!/&My/g

\.[sg]et is the part of the expression that matches either .get or .set
\(Your\)\@! is the part of the expression that is key to matching getHost() but not getYourHost()
& is the part of the expression that takes what is matched and places that match in the replacement
g means to apply the search and replace to all matches on each line


links: Vim Help
Positive and Negative Lookahead

Thursday, July 16, 2009

mount windows network share on linux using cifs

below is the command i used to mount a windows network share on a centos linux system. this is work on any linux distro


> mount -t cifs //nas/share /mnt/point -o user=username,uid=some_user,gid=some_group,rw

Wednesday, July 1, 2009

vimrc customizations

below are the vim customizations I place in my vimrc file

set foldmethod=marker
set nobackup
set nowritebackup
set background=dark
set number

Build Python 2.6 on CentOS 5.3

Build Python 2.6 on CentOS 5.3

download python 2.6.2 tarball
extract python 2.6.2 tarball to /usr/src
E.g., tar -xvjf /share/download/Python-2.6.2.tar.bz2 -C /usr/src

> cd /usr/src/Python-2.6.2
> ./configure
> make

make a symbolic link in /usr/bin for the python 2.6.2 interpreter
> ln -s /usr/src/Python-2.6.2/python /usr/bin/python26

verify that the correct python interpreter is executed
> python26

verify that python 2.6.2 appears in the heading

Wednesday, November 12, 2008

iceweasel not finding jre

i'm currently running debian etch. iceweasel is not finding the sun java jre that i installed using apt. i found the solution at http://xjqian.wordpress.com/2007/11/11/jre-plugin-for-mozilla/ .


after running

aptitude install sun-java6-jre

make a symbolic link

ln -s /usr/lib/jvm/java-6-sun/jre/plugin/i386/ns7/libjavaplugin_oji.so ~/.mozilla/plugins/libjavaplugin_oji.so

restart iceweasel.

success.

Thursday, August 7, 2008

Faster USB Transfers

Problem: Transferring files to my usb harddrive was taking a very long time.
Solutions: Multi-step. Explained below.

Links:
http://www.linuxjournal.com/article/8093
http://www.linuxquestions.org/questions/linux-general-1/slow-pendrive-usb-2.0-uploads-259591/

After reading at the above links, I discovered a few things were causing my problem. First, in /etc/fstab I was mounting my usb drive with the sync option. Change that to async (I think it's the default). Second, the cheap usb hub I bought at a local retailer for ~$10 is not a high speed usb hub. I need to buy a better one.

Third, I think the interface that was in control of the USB controller was not the highest speed module. Evidently there are several interfaces that can be used. On my Debian Etch, ehci and uhci were appearring as loaded modules in the lsmod print out. The uhci_hcd module was grabbing the usb devices according to dmesg. So I used modprobe -r to remove both the ehci_hcd and uhci_hcd modules. Then I used modprobe to install the ehci_hcd. Next I plugged in and mounted my usb harddrive. When transferring files to the usb harddrive I noticed a dramatic increase in transfer speed.

In limited testing (copying one large file with each module loaded), here are some results. With uhci_hcd loaded, I transferred a single 6.1 GB file in 97 minutes 0.033 seconds, for 1.056 MB per second transfer speed. With ehci_hcd loaded, I transferred a single 5.1 GB file in 4 minutes 35.544 seconds, for 21.333 MB per second transfer speed.

So now the question is, how do I guarantee that the ehci_hcd module is loaded instead of the uhci_hcd module? Upon further investigation and testing I've discovered that, I guess it's udev, is smart enough to load the ehci_hcd module when a "high speed" device, like my usb hard drive, is plugged into the usb port. The uhci_hcd module is loaded when a "full speed" device, like my cheap usb hub, is plugged into the usb port.