Category Archives: Geek Stuff

GUADALAJARA, TEQUILA, AND COMPUTING POWER

2012-07-08 14.04.262012-07-08 14.04.462012-07-08 14.04.572012-07-08 14.06.252012-07-08 14.06.30
2012-07-08 14.12.302012-07-08 14.18.412012-07-08 14.19.132012-07-08 14.20.472012-07-08 14.20.562012-07-08 14.28.32
2012-07-08 14.28.492012-07-08 14.40.262012-07-08 15.21.122012-07-08 15.21.45
2012-07-08 14.16.122012-07-08 14.17.142012-07-08 14.33.402012-07-08 14.38.582012-07-09 06.23.032012-07-09 08.53.28

Trip to Guadalajara July 2012, a set on Flickr.

Just sharing some pictures on a trip I took to Guadalajara And Tequila in Jalisco, Mexico July 2012. Most of the time was a lot of long hours working however meal times were pretty awesome. From breakfast at the RIU hotel to the many places we had lunch and dinner, all the meals were great. Also, the day before we left we managed to slip out for a tour of the Tequila distiller for José Cuervo which was pretty cool. Enjoy the pictures.

Getting some functionality back in the system tray on Ubuntu 11.04

Ubuntu 11.04 introduced a new, cleaner user interface called Unity. I’m not a huge desktop GUI guy, doing a large majority of my work in the command line, but I do like to try and stay current on the latest greatest interfaces.

I’m not overwhelmed with Unity. It’s OK but not really earth shattering. You have the option to switch back to the “classic” Gnome interface if you wanted to but I haven’t done that.

One huge annoyance I’ve noticed about the new Unity interface was a lack of a true “system tray”. Many application in Ubuntu (or Linux in general) leverage a similar approach Windows machine do and allow applications to run in a System Tray, cleaning up any task bars you might have. In Unity, there were a couple applications that were visible, like Dropbox, the clock and Volume but several others were not such as Skype and Truecrypt.

This became a big problem for Truecrypt because once I closed the Truecrypt interface I couldn’t figure out how to get back to it. If I tried to launch the application again the system would report that it the application was already running, which it was. In the past I would get back to the interface through the icon in the system tray but this icon would not display in Unity, at least not until I found a posting on Facebook http://www.facebook.com/topic.php?uid=6723083591&topic=17003

This simple command in a terminal window corrected my problem and life is good again
[bash]gsettings set com.canonical.Unity.Panel systray-whitelist "[‘all’]"[/bash]
As you can see I got all my system tray icons back and I am now a little happier with Unity.

 

Screenshot-1

 

Tagged , ,

Reposting a great article I can across for all my PHP buddies out there who want to use Vi for development

The original posting can be found here

http://hameedullah.com/howto-setup-vim-ide-for-php-development.html#

Enjoy

Howto Setup Vim IDE for PHP Development

Howto Setup Vim IDE for PHP Development
As a PHP developer one has quiet a lot of choices of IDE. Some are graphical will built-in features like debugging, code completion, auto indentation, syntax highlighting, code checking and many more. But those IDEs are very heavy and slow to use, and I know many people like me who just can’t live without Vim and want to use Vim for all type of text editing they do, whether they are writing code, editing configuration files or may be creating simple text files.

Recently I posted a screenshot of my Vim editor and got a lot of emails that how did I setup Vim that way. So, I hope this howto will be easy enough for everyone to follow and setup their Vim as their PHP  IDE. For the sake of simplicity I am assuming you are using Vim on Linux or Linux like system. If you are a windows user then this guide should still work for you, but I might not be able to provide Windows related details where needed.

Features that we will add or enable in Vim to make it a complete IDE.

  • Code Completion
  • Tag Lists
  • Project Management
  • Syntax Highlighting
  • Code Checking

First we need to download following Vim scripts and extract them in our ~/.vim directory.

Download above scripts one by one and install them. Installing them is easy just unzip them in you .vim directory which is located in your home directory. Now we need to download few files in our .vim/plugin directory. Download the following Vim scripts directly into your .vim/plugin directory.

Now that you have installed above scripts, you are almost all set to go. You just need to paste the following content in your .vimrc file which is located in your home directory.

[bash]
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ~/.vimrc "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" "
" Version: 0.1 "
" "
" "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Hightlight the ifs and buts
syntax on

" Plugins and indentation based on the file type
filetype plugin indent on

" Don’t remember source of this, i think it was already in my .vimrc
" Tell vim to remember certain things when we exit
" ’10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :5000 : up to 5000 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n… : where to save the viminfo files
set viminfo=’10,"100,:5000,%,n~/.viminfo

" omnicomplete from: http://vim.wikia.com/wiki/VimTip1386
set completeopt=longest,menuone
inoremap <expr> <CR> pumvisible() ? "<C-y>" : "<C-g>u<CR>"
inoremap <expr> <C-n> pumvisible() ? ‘<C-n>’ :
‘<C-n><C-r>=pumvisible() ? "<lt>Down>" : ""<CR>’

"###########################
"## PHP ##
"###########################
" The php doc plugin
" source ~/.vim/php-doc.vim
inoremap <C-P> <ESC>:call PhpDocSingle()<CR>i
nnoremap <C-P> :call PhpDocSingle()<CR>
vnoremap <C-P> :call PhpDocRange()<CR>

" run file with PHP CLI (CTRL-M)
:autocmd FileType php noremap <C-M> :w!<CR>:!/usr/bin/php %<CR>

" PHP parser check (CTRL-L)
:autocmd FileType php noremap <C-L> :!/usr/bin/php -l %<CR>

" Do use the currently active spell checking for completion though!
" (I love this feature 🙂
set complete+=kspell

" disable tabs
set expandtab
set shiftwidth=4
set softtabstop=4

" highlt matches
set hlsearch

" Taken from http://peterodding.com/code/vim/profile/vimrc
" Make Vim open and close folded text as needed because I can’t be bothered to
" do so myself and wouldn’t use text folding at all if it wasn’t automatic.
set foldmethod=marker foldopen=all,insert foldclose=all

" Enable enhanced command line completion.
set wildmenu wildmode=list:full

" Ignore these filenames during enhanced command line completion.
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif " binary images
set wildignore+=*.luac " Lua byte code
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.pyc " Python byte code
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files

" Enable completion dictionaries for PHP buffers.
autocmd FileType php set complete+=k~/.vim/dict/PHP.dict

" PHP Autocomplete
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
set ofu=syntaxcomplete#Complete

" You might also find this useful
" PHP Generated Code Highlights (HTML & SQL)
let php_sql_query=1
let php_htmlInStrings=1
let g:php_folding=2
set foldmethod=syntax

" ——————–
" Project
" ——————–
map <A-S-p> :Project<CR>
map <A-S-o> :Project<CR>:redraw<CR>/
nmap <silent> <F3> <Plug>ToggleProject
"let g:proj_window_width = 30
"let g:proj_window_increment = 150

nnoremap <silent> <F8> :TlistToggle<CR>
let Tlist_Exit_OnlyWindow = 1 " exit if taglist is last window open
let Tlist_Show_One_File = 1 " Only show tags for current buffer
let Tlist_Enable_Fold_Column = 0 " no fold column (only showing one file)
let tlist_sql_settings = ‘sql;P:package;t:table’
let tlist_ant_settings = ‘ant;p:Project;r:Property;t:Target’

" auto change directory from: http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file
autocmd BufEnter * if expand("%:p:h") !~ ‘^/tmp’ | lcd %:p:h | endif

" when we reload, tell vim to restore the cursor to the saved position
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
if expand("<afile>:p:h") !=? $TEMP |
if line("’"") > 1 && line("’"") <= line("$") |
let JumpCursorOnEdit_foo = line("’"") |
let b:doopenfold = 1 |
if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo – 1)) |
let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo – 1 |
let b:doopenfold = 2 |
endif |
exe JumpCursorOnEdit_foo |
endif |
endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
if exists("b:doopenfold") |
exe "normal zv" |
if(b:doopenfold > 1) |
exe "+".1 |
endif |
unlet b:doopenfold |
endif
augroup END

" PHP code sniffer
" If code sniffer is installed you can run it on current php file by running
" :Phpcs
function! RunPhpcs()
let l:filename=@%
let l:phpcs_output=system(‘phpcs –report=csv –standard=YMC ‘.l:filename)
" echo l:phpcs_output
let l:phpcs_list=split(l:phpcs_output, "n")
unlet l:phpcs_list[0]
cexpr l:phpcs_list
cwindow
endfunction

set errorformat+="%f"\,%l\,%c\,%t%*[a-zA-Z]\,"%m"
command! Phpcs execute RunPhpcs()
[/bash]

Thats it, now you are all set to go. Following are the few quick commands to get you started to use all the features you have just enabled in your Vim IDE.

F3: To start using project manager.
C: After starting project manager this key combination will allow you to add new project.
F8: Tag list window
Ctrl+L: To run the syntax checking on your php file
Ctrl+P: On any class/function definition to add php doc strings
“:PhpCs”: To run PHP Code sniffer on your php script. (this requires code sniffer to be installed).
Ctrl+n: On any word to use Auto completion feature of PHP.

I will soon write another howto to explain how can you use further features of your IDE. You should subscribe to the feed or follow me on twitter to stay updated. :)

My Non-Open Source (Proprietary) Guilty Pleasures

Being an “Open Source” guy there is a certain stigma that goes along with that title, one being that everything you use has to be Open Source. Where I take great pride in the knowledge there isn’t really any aspect of my digital life I couldn’t do without an Open Source solution, I personally don’t necessarily make Open Source a “requirement”. I always look for the best solution and tool for a particular task, for me freedom and access to the code weighs heavily in that decision but is not the only parameters in picking a solution.

In the interest of full discloser, and because there are people who enjoy pointing out when they “catch me” not using Open Source (as if I don’t know), I present to you a list of my Non-Open Source guilty pleasures that I use frequently (with some justification for using them)

Note: with the exceptions of OSX and the Microsoft products all solutions below do offer free versions of their products though I typically pay for the upgraded products.

Desktop

  • Evernote (http://www.evernote.com) – There are several alternatives to Evernote, including Open Sources ones such as Tomboy but they all seem to lack either features or cross platform compatibility. Evernote does have a OSX and Windows client but no client for Linux which has always been a huge draw back. Evernote does have a pretty good web interface, which continues to improve and this helps a lot when I am on my Linux desktops. Evernote also have a lot of open APIs and there has been some activity to writing alternative Evernote clients that will run on Linux desktops including one I’ve checked out called Nevernote (http://nevernote.sourceforge.net/)
  • Navicat (http://www.navicat.com/) – I simple like this tool. The user interface and feature set is wonderful. There are tons of Open Source GUI clients to connect to MySQL database and even though 99% on my database activity is connecting to a MySQL backend every now and then I need to connect to MSSQL, Oracle, or PostgreSQL and my Navicat Premium allows me to do this in one client. It also has a wonderful feature of establishing my MySQL connections over SSH which I love when I need to work on my Windows boxes. It’s baked in so I don’t have to establish my own separate SSH tunnel. They also have clients for Windows, OSX, and Linux
  • Dropbox (http://db.tt/AyOLUYV) – I have to be honest, I’ve used Dropbox for several years but it is always on my hit list to move to an alternative Open Source solution. There seems to be a new one that drops every month. When I get comfortable with the staying power and feature set that Dropbox offer, I will probably drop Dropbox.
  • OSX (http://www.apple.com/macosx/) – This is really a decision of convince than anything else. There are typically a greater number “vendor support” desktop application that are not support on Linux desktops such as the previously mentioned Evernote. However OSX is BSD at heart and lets me retain a lot of the Open Source tools I am accustomed to on my Linux desktop including a very power command line and scripting ability. My OSX desktop also affords me the unique benefit of running virtualization software such as Virtualbox (http://www.virtualbox.org/) and allow me to run Windows, several Linux distributions, and OSX all on one physical machine. This is really nice especially when needing to do testing.

Continue reading

SSH AutoComplete on OSX

I am a very heavy user of SSH, like everyday all day type of user. I know a couple cool SSH tricks like port forwarding and mapping remote drives. One thing that always bugged me was the lack of auto complete when I was on my OSX machine. You see with SSH, you can define a bunch of individual host and configurations unique to those host in a file called .ssh/config. It’s a great tool to have and when you do have some host define, on a Linux machine, you can type in the command ssh, then the first couple if letters of the host and hit tab. It will act as any tab completion does for commands and fill in as much of the hostname as it can before it requires some other unique identifier. However, this cool autocomplete feature didn’t happen naturally of my OSX box.

Through the years, I’ve had an idea of what I needed to do to create my own script to handle it. There is the complete command, the trick is grepping the config file and pulling out the right information. I decided to be lazy and just manually created several alias for my ssh server. The alias approach worked, but this grew into a very long list of alias and wasn’t very efficient. So tonight I decided I was going to write the script to meet my needs and about 2 clicks on Google links later, I found someone who had actually already completely done it. Nem W. Schlecht posted his script on a Macworld hints forum a couple years ago. Here is a link to that original thread http://goo.gl/Wd4Z5 but the piece of magic that did the trick is below. As a added bonus, it also creates auto complete from servers it finds in your known_host file. I will repost his post, not just the code, because he has some wise advice on where to place the code

The macports suggestion is a good one, but IMO, includes too much. If you don’t have macports installed, you can add the following to your .bash_profile (I wouldn’t add it to my .bashrc, since that gets read in by cron jobs and remote commands).

Tagged ,

Nasty Bug – Ubuntu 10.04 on VMWare Fusion OSX

Came across a nasty little bug when I installed the latest Ubuntu 10.04 (LTS) into a virtual machine using VMWare Fusion 3.02 on my OSX box. This was a fresh install and the install itself went smooth, the problem occured when the initial login screen appeared. Although my mouse worked just fine and I was able to click on the user to log in, I wasn’t able to type anything. My keyboard was completely unusable within the virtual machine. I was not able to type any input via the keyboard.

After doing some Googling I discovered that once you got past the login screen the keyboard would work fine. The only way to login was to initiate the on-screen keyboard and type in your password. You can bring up the on-screen keyboard by clicking on the Universal Access icon on the lower right hand side of the screen and choosing “Use on-screen keyboard”. One side note here, when I first checked the box to use the on-screen keyboard, the keyboard would flash and disappear. What I needed to do was keep the box check and reboot the machine, when the login screen returned, the keyboard was there.

Once I logged in the physical keyboard worked fine. I was able to use it in all the applications and didn’t notice any problems, but once I logged out and returned to the login screen, again no input from the physical keyboard. Now I needed to fix this.

What didn’t work 😦

At this point I go into basic trouble resolution mode and decided to start by reinstalling and upgrading the VMWare tools. Not going to get into a step by step here how to do that but the short of it is after reinstalling the VMWare tools and rebooting I was stuck in the same situation and needed to use the on-screen keyboard to log in. Next obvious step, apply all patches to the Ubuntu desktop, did this, rebooted, still no go.

What did work 🙂

Clearly, you are not reading this article to learn how not to fix it. Trust me after doing enough searches there are plenty discussion threads out there with “This doesn’t work for me either, anyone fix this yet?” to keep you reading for hours. I found a couple good links that I will post at the end of this article that got things resolved. The short answer is I logged into the machine, fired up and console window, type in the command
[bash]
sudo dpkg-reconfigure console-setup
[/bash]
For keyboard I selected “Apple” and then just selected the defaults for everything else. Once I exited the configuration wizard, I restarted the machine and all was right with the Ubuntu world again. Did a couple reboots to make sure and everything seems to be working fine now.

One more side note

This issue  occurred on a clean install of the current Ubuntu 10.04 LTS release. I had been previously running the beta version of the 10.04 release which worked fine and never had a problem with the keyboard input. However, after patching that box today, same issue occurred.

The Links

Two links basically lead me to my resolution

Tagged , , ,

[Nagios] Error: Could not stat() command file '/var/lib/nagios3/rw/nagios.cmd'!

System: Ubuntu 9.10 | Nagios 3.x

This is another post that is more of a note to myself than anything else. Been doing a lot of Nagios configuring and decided to implement the ability to push commands from the web interface. I followed the basic instructions to configure “External Commands” but after doing and going to the web interface to test it, I got the following error message;
[shell]
Error: Could not stat() command file ‘/var/lib/nagios3/rw/nagios.cmd’!

The external command file may be missing, Nagios may not be running, and/or Nagios may not be checking external commands. An error occurred while attempting to commit your command for processing.
[/shell]
The file was there so I did what any good geek should do, I did a quick google search. The closet thing I could find was some commands to fix the issue on Debian systems. Since I was running Ubuntu, which is for all intensive purposes Debian, I figured I would try it.  So I ran the following set of command;
[bash]
sudo /etc/init.d/nagios3 stop
sudo dpkg-statoverride –update –add nagios www-data 2710 /var/lib/nagios3/rw
sudo dpkg-statoverride –update –add nagios nagios 751 /var/lib/nagios3
sudo /etc/init.d/nagios3 start
[/bash]
This worked like a charm and the web interface began accepting commands.

Tagged , ,

Sony Electronics Creates Open Source Development Community

Last week Sony open the doors to a new web site, as well as a new approach for the organization, called Sony DeveloperSony Developer is meant to become a hub for Open Source development efforts for Sony Electronic products.

Currently, Sony has enabled the community for “SNAP” which is an application framework for consumer electronic devices. From the SNAP site;

“SNAP stands for Sony’s Networked Application Platform and is part of an emerging new ecosystem for making downloadable applications available to networked devices like TV’s, Blu-ray Disk players and other Consumer Electronic products. SNAP is in the very early stages of development and has a lot of room to grow”

This will open an avenue that will allow developers to get their applications onto SNAP enabled devices such as televisions. SNAP is based on the GNUstep community, whose origin dates back to the OpenStep standard developed by NeXT Computer Inc (now Apple Computer Inc.) which also implements the extensions added by Apple in the form of Cocoa. The main language on GNUstep for SNAP is ObjectiveC and the SNAP development web site points a lot of great resources on ObjectC from beginners guide to optimization.

Sony offers a guides and a SDK for download to start with your development efforts. It’s mentioned on the SNAP web site that some good examples of applications would be “Games, Widgets (weather, news, traffic, etc), remote controls, social apps, media sharing apps, media players, home automation”. Also according to the web site Sony will be hosting contest in the future for SNAP developers with prizes ranging from Sony televisions to Sony Walkman.

Another section of the Sony Developer Web site will be the dash section, which is currently unavailable but from what I’ve heard should be opened in the coming weeks. dash is the Sony new Personal Internet Viewer. Developed with Flex, Sony is hoping to encourage and foster application developed on the dash product.

Tagged , ,
%d bloggers like this: