Omar's Blog
Monday, February 27, 2012
Monday, February 6, 2012
Organize your downloads, the OS X way
If you are one of these guys who move files and organize them manually under the correct directory, this blog post isn't for you.
I usually download lots of files and I keep trying to cleanup my Downloads folder in so many ways. First, I configured every application to download in its own folder so I had Firefox, iChat, Mail, etc...
This didn't really help. When the time comes to cleanup the Downloads folder, I usually need to delete very old downloads because I no longer need a software update from mid-2009.
So next I tried one of Firefox's extensions to organize my downloads and used Glims for Safari. The idea was to organize downloaded files in a directory hierarchy where I can identify older files and remove them.
The problem with that solution is that it didn't work for all the applications I use so I decided to write a script to do that for me.
Writing that script in Bash, PHP or Python is an easy job but I wanted to do it the Mac way so I created this AppleScript and attached it to the Downloads folder using Folder Actions in OS X.
Try it out:
http://gist.github.com/445641
I usually download lots of files and I keep trying to cleanup my Downloads folder in so many ways. First, I configured every application to download in its own folder so I had Firefox, iChat, Mail, etc...
This didn't really help. When the time comes to cleanup the Downloads folder, I usually need to delete very old downloads because I no longer need a software update from mid-2009.
So next I tried one of Firefox's extensions to organize my downloads and used Glims for Safari. The idea was to organize downloaded files in a directory hierarchy where I can identify older files and remove them.
The problem with that solution is that it didn't work for all the applications I use so I decided to write a script to do that for me.
Writing that script in Bash, PHP or Python is an easy job but I wanted to do it the Mac way so I created this AppleScript and attached it to the Downloads folder using Folder Actions in OS X.
Try it out:
http://gist.github.com/445641
Thursday, February 2, 2012
My .vimrc
My .vimrc:
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Start-up"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Use Vim settings, rather then Vi settings (much better!).set nocompatible" First clear any existing autocommands:autocmd!" have syntax highlighting in terminals which can display colours:if has('syntax') && (&t_Co > 2)syntax onset hlsearchendif" Filetype pluginsfiletype plugin indent onsetlocal spell spelllang=en"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" General"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set history=1000set viminfo=/10,'10,r/mnt/zip,r/mnt/floppy,f0,h,\"100set wildmode=list:longest,fullset titleset showmodeset showcmdset sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize" Status lineset laststatus=2set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]set modelines=3"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Text Formatting/Layout"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set backspace=indent,eol,startset formatoptions-=tset textwidth=0set isk+=_,$,@,%,#,- " These aren't word dividersset incsearch " do incremental searchingset ignorecase " Do case insensitive matchingset nosmartcase " No smart case matchingset smartindent " smart indentation" Tab settingsset expandtabset showtabline=2set tabstop=2 " tab stop 2 spacesset shiftwidth=2set shiftround" Commentsset comments-=s1:/*,mb:*,ex:*/set comments+=s:/*,mb:**,ex:*/set comments+=fb:*"set comments=s5:/**,mb5:*,ex:*/"set comments=sr:/*,mb:**,ex:*/"set comments+=fb:*"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Theme/Visuals"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set showmatch " Show matching brackets.set background=darkset foldmethod=indentset foldlevel=50set mouse=i " Enable mouse usage in Insert, View and Command line modes in terminalsset ruler " show the cursor position all the timeset number " show line numbers"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" File Handling"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set autowrite " Automatically save before commands like :next and :makeset nobackup " do not keep a backup file, use versions insteadset noswapfileif has("autocmd")" Enabled file type detection and file-type specific plugins." filetype plugin on indentfiletype plugin on" Drupal *.module and *.engine files.augroup moduleautocmd BufRead *.install,*.schema,*.inc,*.module,*.engine set filetype=phpaugroup END" Python code.augroup pythonautocmd BufReadPre,FileReadPre *.py set tabstop=4autocmd BufReadPre,FileReadPre *.py set expandtabaugroup END" PHP code.augroup phpautocmd BufReadPre,FileReadPre *.php set tabstop=2autocmd BufReadPre,FileReadPre *.php set expandtabaugroup END" ANT build.xml files.augroup xmlautocmd BufReadPre,FileReadPre build.xml set tabstop=2augroup ENDendif" Set Drupal files as php syntax-like filesau BufNewFile,BufRead *.module,*.install,*.schema,*.inc set filetype=php"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" PHP Specific Settings"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" PHP Error checkset makeprg=php\ -l\ %set errorformat=%m\ in\ %f\ on\ line\ %l"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Cool Abbreviations""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" HTML"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Print an empty <a> tag.map! ;h <a href=""></a><ESC>5hi" Wrap an <a> tag around the URL under the cursor.map ;H lBi<a href="<ESC>Ea"></a><ESC>3hi"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Cool Shortcuts"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Some keymaps:nnoremap <C-M> <Esc>:w<CR> "Savennoremap <C-O> <Esc>:Texplore<CR> "Show Explorer in a new tabnnoremap <C-N> <Esc>:tabnew<CR> "CTRL+N to open a new tabmap <C-Right> <Esc>:tabn<CR> "CTRL+Down to view next tabmap <C-Left> <Esc>:tabp<CR> "CTRL+Up to view previous tabno <C-E> <Esc>:mks! ~/.vimsession<CR> "CTRL+E saves the current session to ~/.vimsession" Don't use Ex mode, use Q for formattingmap Q gqmap q :q<CR>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Explorer""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Make Explorer open files in new tabslet g:netrw_browse_split=3
Push-any Git post-update hook
Maintaining multiple branches in Git is very easy. Maintaing multiple "remotes" in Git is very easy. The tricky part comes when you join both.
Unless you have a testing, staging and production server and you maintain a branch per-server, aka remote, then you need to git your hands dirty with some code.
The other day, I wanted to have a single remote for testing multiple branches and the web had half the answer with this script, but unfortunately, it doesn't checkout the branch you're pushing.
After few lines of code, I can now push multiple branches to a non-bare remote repository and have the post-update automatically checkout the branch I pushed and update the worktree, handy huh?
Code is here. Your comments are welcome.
Unless you have a testing, staging and production server and you maintain a branch per-server, aka remote, then you need to git your hands dirty with some code.
The other day, I wanted to have a single remote for testing multiple branches and the web had half the answer with this script, but unfortunately, it doesn't checkout the branch you're pushing.
After few lines of code, I can now push multiple branches to a non-bare remote repository and have the post-update automatically checkout the branch I pushed and update the worktree, handy huh?
Code is here. Your comments are welcome.
Subscribe to:
Posts (Atom)