• Home
  • Blogger
  • Github
  • Travel
  • The Tank Project
skip to main | skip to sidebar

Steven Occhipinti

A braindump.

Disabling the Unity global menu

The Unity global menubar in Ubuntu can take a bit of getting used to, especially if you don't come from a Mac background, but once you do, the screen real estate saving is quite nice, especially on small screens like my eeepc.

But sometimes it can be frustrating!
For example, if you use The Gimp, alot of its functionality is in the menu, but for that to show, you must have the main window (the one with your work in it) focused, but whenever you select a tool from the toolbox, that window loses focus, and therefore you can't get to the menu.

I know all it takes is a click in the main window and then a click on the global menu, but this can get quite annoying.

Thankfully, there is an off-switch in the form of an env-var which you can either add to your profile to completely disable it, or just prefix it before you run commands like gimp.

All you need to do to disable it is set this:
UBUNTU_MENUPROXY=0

I made an alias so its easier to remember:
alias dam='UBUNTU_MENUPROXY=0 '

Note that typing (or shouting) dam gimp is not only to relieve the frustration of the global menubar, but it also stands for "Disable AppMenu" :)

There is a full write up with more details over at webupd8.org
Posted by Steve at 22:56 0 comments
Labels: linux , ubuntu , ui , unity Email This BlogThis! Share to X Share to Facebook

Recursive search with vimgrep

Usually when I need to find things in multiple files, I would use grep or ack from a terminal and then open those files in vim to do whatever it is that I have to do.

This is ok, but sometimes this can be a little annoying.
Vim has a :grep function which will use the system grep command, but it also has a :vimgrep function that is built in to vim.

I had left a bunch of TODO's through out my code as a reminder to come back to them, so using :vimgrep I was able to quickly jump between them:

:vimgrep TODO **/*

This tells vim to search for the pattern "TODO" recursively from the current directory.
The "**/" means recursive and the "*" means any file - therefore "**/*.rb" would just search the ruby scripts.

The results are loaded into the "quickfix window". This means if you want to see all the occurences, you can open the list with :copen
Naturally, :cnext, :cprevious, :cfirst, :clast, etc. will allow you to jump between them or you can use the quicklist window and press enter on the filename, or in gvim you can even use the mouse.

In addition, I use Tim Pope's Unimpaired vim plugin,which provides the easy shortcuts '[q' and ']q' for :cprevious and :cnext (respectively)
Posted by Steve at 13:46 0 comments
Labels: regex , vim Email This BlogThis! Share to X Share to Facebook

Ruby + parallel port + LEDs

In the initial R&D stages for our Tank Project we have to work out the most suitable way to interface from software to hardware - which I have never done before!


The parallel port

One of those options is to use the parallel port, which allows us 8 data pins that we can use for controlling motors, etc.
The layout of a parallel port is quite easy, there are 8 "D" pins for data with 8 matching "Ground" pins (shown in green below).

The test rig

As the output from the parallel port is about 5 volts, I though LED's were a suitable was of testing this out, so I went searching through our garage to find a parallel cable from an old printer and a bunch of LED's.
I found a bunch of tristate LED's - tristates have 3 legs instead of 2 and provide 2 different colors depending on which legs have power to them.
For example, if the circuit connects the left leg and the middle leg, it produces green light, whereas the right leg and middle leg produce red light.
Soldering 4 of these LEDs to a board meant I could join all the middle legs together which would be what I connect the ground wire from the parallel port to and the other 8 legs to the 8 data wires.


The software

In order to control when each of the data pins has power to it or not, you simply have to write 8 bits (a byte) to the parallel port where each bit corresponds to a data pin.
In linux this is quite simple as you can write to /dev/port just like any other file.
To test this out, I wrote a little Ruby script to play a fancy little sequence a few times. The code is quite simple considering some other examples on the net:



The fun part!

So my computer doesn't have a parallel port, but we have some older machines that do. So I found an old pc and booted off a linux live distro that has ruby, plugged in the cable with the LEDs on it, and ran my script, and this is what happens:
The conclusion

This is the first time I have ever written a program that uses hardware, albeit really basic hardware, but this has a lot of potential.
Instead of turning on lights, this small current could trigger relays to do more exciting things, or in our case power transistors using PWM to control motor speed for our tank - and its so simple!
Posted by Steve at 14:49 2 comments
Labels: hardware , linux , parallel port , programming , ruby , tank Email This BlogThis! Share to X Share to Facebook
Newer Posts Older Posts Home

Blog Archive

  • ►  2013 (4)
    • ►  June (1)
    • ►  May (1)
    • ►  March (1)
    • ►  January (1)
  • ►  2012 (17)
    • ►  December (1)
    • ►  October (1)
    • ►  September (2)
    • ►  August (2)
    • ►  July (1)
    • ►  May (2)
    • ►  April (2)
    • ►  March (3)
    • ►  February (3)
  • ▼  2011 (33)
    • ►  December (1)
    • ►  November (3)
    • ▼  October (3)
      • Disabling the Unity global menu
      • Recursive search with vimgrep
      • Ruby + parallel port + LEDs
    • ►  September (4)
    • ►  August (3)
    • ►  July (4)
    • ►  June (6)
    • ►  May (6)
    • ►  April (3)

Labels

android (5) apache (1) arch linux (1) arduino (1) bash (11) calendar (1) compiz (1) design (1) diff (1) email (1) gimp (1) git (3) github (2) gnome3 (1) Google (2) hacking (1) hardware (4) howto (1) htpc (1) java (1) lamp (1) linux (28) Mac (2) minecraft (2) mysql (1) netduino (1) nfs (1) parallel port (1) patch (1) photography (4) php (1) pidgin (2) printer (1) programming (6) python (1) rails (1) regex (5) review (3) ruby (3) Samsung Galaxy S3 (2) Samsung Series 9 (1) security (1) sed (3) ssh (1) sudo (1) tank (2) Toshiba Portege (1) troubleshooting (1) ubuntu (16) ui (2) unity (2) vim (5) webcam (1) websites (3) xbmc (1) xclip (1) xul (1)

Total Pageviews

Sparkline
 
Copyright (c) 2010 Steven Occhipinti. Designed by Conveyancing
High Deductible Health Insurance, Purchase Beats