Thursday, May 13, 2010

renaming all files in a directory

some of the simple things in live




for x in *.php5; do n=${x/.php5/.php}; mv $x $n; done



taken from here

http://www.debianadmin.com/rename-multiple-files-to-another-extension-in-linux.html

Friday, May 7, 2010

moving indexes in postgres to a new tablespace

Recently I upgraded my server and added a SSD raid system of 3 128GB disks and for obvious reasons want to have my indexes on it. So the first step was to create a new tablespace


create tablespace 'name' owner 'owner' location 'directory'


and than creating a quick script to move all the indexes


select 'ALTER INDEX '||indexname||' SET TABLESPACE compoundindex ;' from pg_catalog.pg_indexes where schemaname = 'public' order by tablename;


which than just needs to be executed

Tuesday, May 4, 2010

using perl to replace all occurences of a word with another in large files

rather simple, we want to replace all occurences of the word 'volatile' with 'volatile2' in a large text file and so just execute


perl -i -p -e 's{volatile}{volatile2}g' /mnt/storage/data/export


I can't believe I'm using perl again...

flushing BinBase

once in a while you think you want to reprocess all data in a binbase database and for this reason you want to flush all the content except the retention index standards. This should never be required, but if you decided to regenerate all the bins with different settings, well you gotta do what you gotta do.

here is a quick sql script todo this for you



delete from comments

go

delete from sample_info

go

delete from meta_key

go

delete from metainformation

go

delete from runtime

go

delete from bin_compare

go

delete from virtual_bin

go

delete from bin a where a.bin_id not in (select bin_id from standard)

go

delete from samples a where a.sample_id not in (select sample_id from bin)

go

delete from reference_class

go

delete from reference

go

delete from result_link

go

delete from bin_ratio

go

delete from bin_references

go

delete from classification

go

delete from configuration where configuration_id not in (select configuration_id from samples)

go

delete from spectra where sample_id not in (select sample_id from samples)

go

delete from qualitycontrol

go

delete from result

go

delete from standard_hist

go

delete from structure

go

delete from substance_classes

go

delete from synonyme

go

delete from user_validation

go

delete from substance_classes

go