20110805

svn diff coloured (vim) + citi sīkumi

grep -rin 'text' ./ --include=*.php
find -name '*.php' -exec egrep -Hn 'SEARCHTERM' {} \;
find . -exec grep -H -n 'hello' {} \;
delete ALOT of logfiles:
find . -type f -name "*.log" -delete

treeview in console:
find . -type d -print | sed -e 's;[^/]*/;|__;g;s;____|; |;g'

svn diff file.ext | view -


http://www.zalas.eu/viewing-svn-diff-result-in-vim

P.S. SVN DIFF with previous version:
svn diff -r PREV file

svn diff -r HEAD:PREV file


SVN PROPGET
svn proplist .
svn propget -R svn:ignore .
svn propedit svn:ignore .


SVN CACHE IGNORE (previously commited)
$ cd /path/to/cache/folder
$ svn stat
###bunch of M's...
$ svn rm * --keep-local
$ svn ci -m 'clearing cache'
$ svn propset svn:ignore '*' .
$ svn up
$ svn ci -m 'cache ignored'


P.S.S. Delete files like 'tmp_*' last accessed at least 2 days ago:
find . -name 'tmp_*' -atime +2 -exec rm {} \;

Number of files in directory:
ls | wc -l

Directory size:
du -hs

Check syntax errors in php script:
php -l ./script.php

TAB settings in Vim:
:set tabstop=4
:set shiftwidth=4
:set expandtab
:retab

Delete ALOT of files:
find /home/dir/ -name "*.tmp" | xargs /bin/rm


How to maintenance page:
http://www.techiecorner.com/97/redirect-to-maintenance-page-during-upgrade-using-htaccess/
mysqldump .. parameters.. | gzip > db_backupfile_tablename.sql.gz

quick dump - NB! could be inconsistent state:
mysqldump -h hostname -u username -ppassword --lock-tables=false --quick dbname | gzip > dbname.sql.gz
gunzip < dbname.sql.gz | mysql -h hostname -u username -ppassword dbname

select av.ModulID, GROUP_CONCAT(distinct av.ID order by av.ID SEPARATOR '&') as concatted from Lang l left join AttributeValue av on l.ID = av.LangID where TextKey like 'si_%' and l.ModulID = 21 group by av.ModulID;

select table_schema, (SUM(data_length) + SUM(index_length))/1048576 as size_in_MB from information_schema.tables where table_schema = 'db_name' group by table_schema;

select table_schema, table_name, (SUM(data_length) + SUM(index_length))/1048576 as size_in_MB from information_schema.tables where table_schema = 'db_name' group by table_schema, table_name;

create database dbname;
grant usage on *.* to dbuser@localhost identified by 'dbpass';
grant all privileges on dbname.* to dbuser@localhost;

Linux:
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
/etc/init.d/mysqld restart
OSX:
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server restart

sql injection: http://websec.ca/kb/sql_injection

http://vim.wikia.com/wiki/Search_and_replace
:highlight Comment ctermfg=green/blue/yellow

php style: http://pear.php.net/manual/en/standards.php

global search/replace with grep and sed:

grep -rl --include="*.php" "oldstring" . | xargs sed -i 's/oldstring/newstring/g'

Nav komentāru: