Wednesday, October 22, 2008

Add recent items to Dock

defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }'

I can't remember where I got this from, but the link in the title takes you to a page with more of the same....

As do:

Tuesday, September 02, 2008

Using find to delete files

I pretty much always forget how to use find. So here's how you delete a bunch of files (handy for those of us who sync things from a mac to a linux box):

find . -type f -name ".DS_Store" -exec rm -f {} \;

[from here]

Friday, June 27, 2008

Find and replace in files

awk '{gsub(/CmdLineArgs.opts.baseUrl/, "$context.ConfigParser().get(\"setup\", \"basepath\")", $0); print > FILENAME}' *

from here and here.

Wednesday, March 12, 2008

Creating new tables from queries

The following is kind of handy:


create table new_table_name as select * from old_Table_name;

for instance:

create table phedex_node_cms_name_map as
select phedex_node.id as node_id, cms_name.id as CMS_NAME_ID
from phedex_node
inner join cms_name
on phedex_node.site = (select site_id from site_cms_name_map where CMS_NAME_ID=cms_name.id)

or even more awesomely:

create table phedex_node_cms_name_map as
select NODE_ID, CMS_NAME_ID from(
select phedex_node.name as node, cms_name.name as cmsname, phedex_node_cms_name_map_tmp.cms_name_id, phedex_node_cms_name_map_tmp.node_id
, regexp_substr(cms_name.name,'_[A-Z]+$',1)
from phedex_node
join phedex_node_cms_name_map_tmp on phedex_node_cms_name_map_tmp.node_id = phedex_node.id
join CMS_NAME on CMS_NAME.id = phedex_node_cms_name_map_tmp.cms_name_id
where phedex_node_cms_name_map_tmp.node_id in (
select node_id from (
select count(node_id) as count, node_id from phedex_node_cms_name_map_tmp group by node_id
) where count > 0
)
and
regexp_like (phedex_node.name,regexp_substr(cms_name.name,'_[A-Z]+$',1))
order by CMSNAME)