Monday, June 25, 2012

Lenovo T410 nVidia Display Brightness in Linux Mint

Linux Mint uses opensource nouveau driver for nVidia graphics and works fine. There is no additional configuration needed. But if you use binary driver you may experience that brightness function keys do not work.

First of all make sure to run nvidia-xconfig in order to create xorg.conf. This step is optional if you use the driver installer. The installer provides a wizard where you can allow to create customized xorg.conf.

Edit /etc/X11/xorg.conf and add the following option to the Device section:

Section "Device"
    ...
    Option "RegistryDwords" "EnableBrightnessControl=1"
EndSection

You might have to restart X server to use new settings.

Monday, June 18, 2012

Deploy Rails 3 Application to Google App Engine Using Warbler

So far Google App Engine does not support ruby/rails applications but there is a way to build a Java servlet using warbler and deploy it to GAE.

Prerequisites

  • GAE SDK 1.6.6
  • Ruby 1.8.7 with rubygems
  • Bundler 1.1.4

Now we're going to install required tools. I already have an account created on GAE but if you don't you should sign-up first to GAE.

Get the latest SDK and extract it locally:

$ sudo unzip google_appengine_1.6.6.zip -d /opt

Install Ruby, Rubygems and Bundler

$ sudo apt-get install ruby rubygems -y

$ sudo gem install bundler

Create a Rails 3 application

Make an application directory and init a Gemfile.

$ mkdir warbler-test && cd warbler-test && bundle init

Add a Rails gem dependency and install it using bundler in a separate directory called vendor. This will make sure your gems are isolated from the system. Also we'll need an extra gem called therubyracer for generating assets. Your Gemfile should look like this:

# A sample Gemfile
source "https://rubygems.org"

gem "rails"
gem "therubyracer", :platforms => :ruby

$ bundle install --path vendor

Bootstrap the Rails 3 application in the current directory (warbler-test). The rails bootstrap script will ask to overwrite the Gemfile. It is safe to allow:

$ bundle exec rails new .

Add warbler gem dependency to the end of Gemfile:

...
# Use warbler to create war
group :development do
  gem "warbler"
end

Run bundle install once again since the Gemfile was changed by the rails script. It is not necessary to specify --path vendor because bundler already configured the application config to use isolated directory

Run the rails server and verify your application is available locally at http://0.0.0.0:3000

$ bundle exec rails server

Deploy the application

When you see it is ready to be deployed, create a war file using warbler. This will create warbler-test.war file taking your current directory as a file name:

$ bundle exec warble war

The final step is to create appengine-web.xml deployment descriptor file and upload using GAE SDK tools.

Extract just generated war file

$ unzip warbler-test.war -d war

Create the descriptor with the following content by changing the [web_app_id] to your GAE application id:



  [web_app_id]
  1
  false

Finally, deploy your application. This step will take some time, probably a couple of minutes to complete:

$ /opt/appengine-java-sdk-1.6.6/bin/appcfg.sh update war

After the deployment completes you should be able to access your application on GAE. Note the prefixed version in the URL, it is a <version>1</version> that we configured in the appengine-web.xml descriptor. In my case the URL is http://1.warbler-test.appspot.com/

Thursday, June 14, 2012

Outline Single Tab in Firefox with ColorfulTabs

Sometimes it happens that you need to pay a special attention on site you are working with. It could be a production site where you have a read/write account but should be careful to prevent of doing changes by mistake. I have found a simple way to outline such sites with color in Firefox using ColorfulTabs add-on.

After the installation you may see a default coloring of tabs like this:

As for me that number of colors is a bit annoying and does not look like I want it to be. So I want to outline only domains I need to pay my attention on.

Open preferences of ColorfulTabs add-on. In the General section change the Use Default Palette to Generate Colors By Domain Hostname:

Then remove everything in Presets section and add this instead:

Now you got two domain patterns (that are regular expressions) and tab color chosen. Make sure the order of domain patterns is correct - the most restrictive patterns should go lower. The .* means any domain and .*massivecoding.blogspot.com is my special site.

Finally, the add-on behaves as expected:

Wireshark For Non-Superusers

A couple days ago I was need to see how the RTMP streaming protocol works. I decided to use Wireshark which is an awesome tool to analyze network traffic with nice user interface and live capturing behavior powered with filtering options.

First, you need to install it. I use Linux Mint which provides Wireshark from repository:

$ sudo apt-get install wireshark -y

This package provides dumpcap utility to capture and dump packets. In Debian and compatible distros such as LMDE it does not allow to use the utility for non-root users by default. You may see the warning box after Wireshark start in this case:

In order to change this I did the following:

Run the configuration script wizard for the package and answered Yes to allow usage for non-superusers:

$ sudo dpkg-reconfigure wireshark-common

If you get this warning after a new capture start, you should add your user to the wireshark group:

by doing the following:

$ sudo gpasswd -a <user> wireshark

After logging out and logging in I was able to use Wireshark.

Tuesday, June 12, 2012

NetBeans SQL Error On Non-null Date Values

I have a column of date type in MySQL database which is not null and value is set to default '0000-00-00'. When I try to fetch a row with a date values composed entirely of zeros in NetBeans's Database Explorer I get the following error:

Error code 0, SQL state S1009: Value '0000-00-00' can not be represented as java.sql.Date Line 1, column 1

This is an error from the JDBC driver which is used by NetBeans to connect MySQL server. The default behavior of the database driver is to raise an exception. To change this you need to pass an additional property to the JDBC connection URL:

jdbc:mysql://localhost:3306/test?zeroDateTimeBehavior=convertToNull

Other possible values of the property are the default exception and round.

More info can be found here: http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html

Monday, June 11, 2012

Recover Subversion Credentials

If happened that you have forgot your subversion credentials there is a chance you have stored it as a plain text under your home directory. This works only if you allows subversion to store passwords locally unencrypted:

$ ls $HOME/.subversion/auth/svn.simple

You will find some directories with hash names. One on those contains a text file with your password.

OpenConnect VPN on Linux Mint 13 Maya (LMDE)

I have just installed a Linux Mint 13 spin based on Debian packages which is called LMDE. It is pretty fast and polished distro with a MATE desktop environment out of the box. But I did not found some packages to be able to Cisco AnyConnect VPN using OpenConnect. So if you do not want to wait that packages to appear in Mint's repository, here's a quick workaround.

First you need to download them manually from the Ubuntu Oneiric repository:

$ wget http://mirror.pnl.gov/ubuntu/pool/universe/n/network-manager-openconnect/network-manager-openconnect_0.9.0-0ubuntu1_amd64.deb http://mirror.pnl.gov/ubuntu//pool/universe/n/network-manager-openconnect/network-manager-openconnect-gnome_0.9.0-0ubuntu1_amd64.deb

Install the packages:

$ sudo dpkg -i network-manager-openconnect*

Also you need to install required dependencies:

$ sudo apt-get -f install

Finally, restart network-manager to use OpenConnect connection type:

$ sudo service network-manager restart

Now, you should be able to create a new VPN connection using nm-applet: