Skip to content

Instantly share code, notes, and snippets.

@lukmdo
lukmdo / gist:239164
Created November 20, 2009 00:12
MySQL Install&More
INSTALL
=======
1. get the wright source distribution (watch for _64 unless it matches your machine echitecture)
2. cd /usr/local
3. sudo tar -zxvf /path/to/mysql-VERSION-OS.tar.gz
4. sudo ln -s full-path-to-mysql-VERSION-OS mysql
5. cd ./mysql
6. sudo chown -R mysql .
7. sudo chgrp -R mysql .
8. sudo scripts/mysql_install_db --user=mysql
@lukmdo
lukmdo / PostgreSQL postInstall
Created December 10, 2009 21:46
PostgreSQL postInstall
To create a database instance, after install do
sudo mkdir -p /opt/local/var/db/postgresql83/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql83/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb'
@lukmdo
lukmdo / MySQL CSV
Created December 10, 2009 21:51
MySQL export data to CSV
SELECT * INTO OUTFILE '/tmp/output.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM table_name
@lukmdo
lukmdo / Django & buildout
Created December 14, 2009 08:56
Django & buildout
======================= buildout.cfg =======================
[buildout]
unzip = true
develop = .
eggs =
ws_ha_transitory
ipython
ipdb
MySQL-Python
docutils
@lukmdo
lukmdo / NETwork stuff
Created January 23, 2010 23:31
NETwork troubleshooting
sudo ifconfig eth0 192.168.1.50 netmask 255.255.255.0 up
sudo ifconfig eth0 hw 00:00:00:00:00:00
sudo route add default gw 172.16.236.0
Display current active Internet connections:
netstat -nat
Display open ports
sudo netstat -tulp || sudo netstat -tulpn
@lukmdo
lukmdo / Mysql generate data
Created January 25, 2010 12:41
MySQL generate data
# Create Fixed row_format table (better indexes than for Dynamic)
mysql> CREATE TABLE test_tab (
id int(11) unsigned NOT NULL AUTO_INCREMENT,
id_2 int(11) unsigned NOT NULL,
id_3 int(11) unsigned NOT NULL,
name char(10) NOT NULL,
c_date date NOT NULL,
mtime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id)
) ENGINE=MyISAM
@lukmdo
lukmdo / MYSQL DBA
Created February 24, 2010 12:03
MySQL DBA
DB table sizes overview
=======================
SELECT TABLE_NAME, TABLE_ROWS FROM information_schema.tables WHERE TABLE_SCHEMA = DATABASE() ORDER BY TABLE_ROWS DESC;
@lukmdo
lukmdo / Gearman install instructions (Perl)
Created March 9, 2010 13:41
Gearman install instructions (Perl)
1. First get libevent as it is required by next step. In case you have it jump to the next step
http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
tar -xzvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable/
./configure
make
make install
2. Get C source and build Gearman
wget http://launchpad.net/gearmand/trunk/0.12/+download/gearmand-0.12.tar.gz
@lukmdo
lukmdo / Gearman - intro
Created March 9, 2010 14:07
Gearman4Perl and in general
1. Start gearman `server` on some machine (here `worker` machine):
$ gearmand --port 8888
2. Connect a `worker` to the server
$ gearman -h IP -p 8888 -w -f test wc
$ gearman -h 127.0.0.1 -p 8888 -w -f test executable_script
3. Push a job to queue by calling:
$ gearman -h IP -p 8888 -f test "SOME DATA TO PROCESS OR ARGS"
Notes:
* Gearman does NOT spawn any `worker` processes, therefore if a number of `workers`
@lukmdo
lukmdo / AWK code repo.awk
Created April 7, 2010 11:23
AWK code repo
BEGIN {begin=0;end=0}
{
if ($1 == "Open_features:") begin=1
if (begin && $1 == "") end=1
if (begin && !end && $1 != "#" && $1 != "Open_features:") OUT[$NF] = 1
}
END {for (key in OUT) print key}