I rarely use anything beyond named parameters, but this post captures what you need to know.
http://kbyanc.blogspot.com/2007/07/python-aggregating-function-arguments.html
Tuesday, 29 September 2009
Wednesday, 23 September 2009
Formatting Output from MySQL prompt
I'm not the biggest fan of MySQL and on the occasions I do use it I always forgot how to get useful results from my queries. To get results paged to less and have them display vertically, you can do this
mysql> \P less
PAGER set to 'less'
mysql> select * from blahblah \G
mysql> \P less
PAGER set to 'less'
mysql> select * from blahblah \G
Restore Mysql Database from the .frm .MYI and .MYD files
OK so you have a mysql database that you have recovered from a backup. However, whereas you would normally have a nice sql dump to deal with, on this occasion you only have the .frm .MYI and .MYD files. Can you rescue that table the client has deleted? Indeed you can!
#> cd [where you databases are kept, possibly /var/lib/mysql ]
#> mkdir [name of database to rescue]
copy the .frm .MYI and .MYD files into it.
make sure the permissions are ok. Something like this
#> chown -R mysql:mysql [dbname]
#> chmod -R 700 [dbname]
Now if you are lucky, you should be able to do this:-
#> mysql -u root databasename -e "SHOW TABLES;";
#> mysqldump -u root databasename tablename
#> cd [where you databases are kept, possibly /var/lib/mysql ]
#> mkdir [name of database to rescue]
copy the .frm .MYI and .MYD files into it.
make sure the permissions are ok. Something like this
#> chown -R mysql:mysql [dbname]
#> chmod -R 700 [dbname]
Now if you are lucky, you should be able to do this:-
#> mysql -u root databasename -e "SHOW TABLES;";
#> mysqldump -u root databasename tablename
Monday, 21 September 2009
Essential HPing3 and TCPDump
HPing3
# Send 2 syn packets to port 80 on a host
hping3 -c 2 -S -p 80 example.com
# scan a some specfic ports on host
sudo hping3 -S example.com --scan 143,220,993,25,80
TCPDump
# capture packets on -ivenet0 interface, don't resolve addresses or port name (-nn) don't capture ssh traffic
tcpdump -ivenet0 -nn not tcp port 22
# the same as above but don't print minimal information (useful as a quick guide to see whats going over the wire)
tcpdump -ivenet0 -nn -q not tcp port 22
# specify a port and destination
tcpdump -ieth0 tcp port 443 and dst example.com
# capture all payload (-s0) and print it in ASCII format (-v -A)
tcpdump -ivenet0 -s0 -nn -v -A not tcp port 22
# dump all packets and payload to file
tcpdump -s0 -ieth0 port 80 -w localhostdump.pcap
# Send 2 syn packets to port 80 on a host
hping3 -c 2 -S -p 80 example.com
# scan a some specfic ports on host
sudo hping3 -S example.com --scan 143,220,993,25,80
TCPDump
# capture packets on -ivenet0 interface, don't resolve addresses or port name (-nn) don't capture ssh traffic
tcpdump -ivenet0 -nn not tcp port 22
# the same as above but don't print minimal information (useful as a quick guide to see whats going over the wire)
tcpdump -ivenet0 -nn -q not tcp port 22
# specify a port and destination
tcpdump -ieth0 tcp port 443 and dst example.com
# capture all payload (-s0) and print it in ASCII format (-v -A)
tcpdump -ivenet0 -s0 -nn -v -A not tcp port 22
# dump all packets and payload to file
tcpdump -s0 -ieth0 port 80 -w localhostdump.pcap
Setting-up Pylons in 5 mins
Really just a recap of http://pylonshq.com/docs/en/0.9.7/gettingstarted/#installing
Here we go
#> wget http://www.pylonshq.com/download/0.9.7/go-pylons.py
#> python2.6 go-pylons.py mydevenv
Everytime we work on a virtual pylons installation run the following script
#> source mydevenv/bin/activate
Create a new project
#> paster create -t pylons helloworld
Create a controller
#> paster controller hello
Fireup the webserver on localhost:5000
#> paster serve --reload development.ini
Here we go
#> wget http://www.pylonshq.com/download/0.9.7/go-pylons.py
#> python2.6 go-pylons.py mydevenv
Everytime we work on a virtual pylons installation run the following script
#> source mydevenv/bin/activate
Create a new project
#> paster create -t pylons helloworld
Create a controller
#> paster controller hello
Fireup the webserver on localhost:5000
#> paster serve --reload development.ini
Building Python from Source
How easy it is to install python from source? Very.
./configure --prefix=/usr/local/python2.6/
make (took 4mins on my x86_64 dc)
make install
./configure --prefix=/usr/local/python2.6/
make (took 4mins on my x86_64 dc)
make install
Subscribe to:
Posts (Atom)