Saturday, January 29, 2011

Set up PCMCIA Sandisk compact flash card adapter import on Ubuntu 10.10

I followed these instructions.
>sudo fdisk -l
Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x41ab2316
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1           9       72261   83  Linux
/dev/sda2   *          10        5487    44002035    7  HPFS/NTFS
/dev/sda3            5488       14594    73145994    f  W95 Ext'd (LBA)
/dev/sda5            5488        5749     2104483+  82  Linux swap / Solaris
/dev/sda6            5750        8360    20972826   83  Linux
/dev/sda7            8361        9588     9857293+  83  Linux
/dev/sda8            9588       14383    38514688   83  Linux
/dev/sda9           14383       14594     1694720   82  Linux swap / Solaris
Disk /dev/sdb: 1024 MB, 1024966656 bytes
32 heads, 63 sectors/track, 993 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1         993     1000912+   6  FAT16
Be sure to note what you see after "/dev", you might have "hde1" instead of "sdb1"
> sudo mkdir /media/cfcard
> sudo mount /dev/sdb1 /media/cfcard
- right click on desktop -> create launcher
- Name: SD mount
- Command: gksu mount /dev/sdb1 /media/cfcard
- Open up Shotwell Photo Manager and you can import the photos.  Or you can go to Computer to see the files.

Friday, January 28, 2011

Setup USB camera import on Ubuntu 10.10

I have a little Kodak Easyshare camera, which I use USB to import photos to my laptop.  It's the first time I tried to import photos since I upgraded from Ubuntu 8.04 to 10.10.

I had a series of problems:


1. Problem: Nothing happened when I plugged in my camera.  In 8.04, F-stop would automatically pop out.
> lsusb
shows that the camera is recognized.
Fix: After some research, I learned that F-stop has been replaced by Shotwell Photo Manager.  Which I installed with:
> sudo add-apt-repository ppa:yorba/ppa
> sudo apt-get update
> sudo apt-get install shotwell
To open Shotwell: Applications -> Graphics -> Shotwell Photo Manager.


2. Now I plug in my camera and something pops up (twice).  But it's an error message:
Unable to mount Kodak EasyShare ... Digital Camera
Error initializing camera: -60: Could not lock the device
Fix: Apparently there is some issue with the camera not wanting to release pictures freely.  So I got gPhoto to resolve this.
> sudo apt-get install gphoto2


3. Now when I try plugging in the camera: (Somehow I still get a duplicate, whatever)
- Ignore any error messages. 
- Click on the window that opens Shotwell Photo Manager
- Click the option that unmounts the camera, wait for a while.
- Should now see a preview of all the images on your camera.
Wait until it finishes
- Click on "Import All"

DDDD Failed hack

DDDD conferenc's registration was full, but they said that there is a way to register by hacking into the source. I failed however, but it was another Ruby learning experience. (Someday I *will* learn Ruby!)

I did end up going to the conference by just showing up. I had a great time.

====

I downloaded the DDDD source. I think I should have it running by doing something similar to "ruby script/server". So I went into tho "scripts" folder and saw two executable files: "cucumber" and "rails".

> ruby cucumber
     /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require': no such file to load -- cucumber (LoadError)
 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
 from cucumber:8

So I tried the next one:

> ruby rails
     /home/haoqili/Desktop/rails/dddd-48f1b10/config/boot.rb:9: uninitialized constant Bundler (NameError)
 from rails:5:in `require'
 from rails:5

> sudo gem install bundler
      Fetching: bundler-1.0.9.gem (100%)
      Successfully installed bundler-1.0.9
      1 gem installed
      Installing ri documentation for bundler-1.0.9...
      Installing RDoc documentation for bundler-1.0.9...

> ruby rails
     /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/source.rb:552:in `load_spec_files': git://github.com/thoughtbot/akephalos.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/source.rb:366:in `local_specs'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/source.rb:535:in `specs'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/definition.rb:147:in `resolve'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/definition.rb:145:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/definition.rb:145:in `resolve'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/definition.rb:90:in `specs'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/definition.rb:135:in `specs_for'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/definition.rb:124:in `requested_specs'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/environment.rb:23:in `requested_specs'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:11:in `setup'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler.rb:101:in `setup'
 from /home/haoqili/Desktop/rails/dddd-48f1b10/config/boot.rb:8
 from rails:5:in `require'
 from rails:5

> bundle install
Fetching git://github.com/thoughtbot/akephalos.git
remote: Counting objects: 754, done.
remote: Compressing objects: 100% (327/327), done.
remote: Total 754 (delta 377), reused 733 (delta 367)
Receiving objects: 100% (754/754), 29.63 MiB | 1.32 MiB/s, done.
Resolving deltas: 100% (377/377), done.
Fetching source index for http://rubygems.org/
^[[A^[[BInstalling rake (0.8.7) 
Installing abstract (1.0.0) 
Installing activesupport (3.0.3) 
Installing builder (2.1.2) 
Installing i18n (0.5.0) 
Installing activemodel (3.0.3) 
Installing erubis (2.6.6) 
Installing rack (1.2.1) 
Installing rack-mount (0.6.13) 
Installing rack-test (0.5.7) 
Installing tzinfo (0.3.24) 
Installing actionpack (3.0.3) 
Installing mime-types (1.16) 
Installing polyglot (0.3.1) 
Installing treetop (1.4.9) 
Installing mail (2.2.14) 
Installing actionmailer (3.0.3) 
Installing arel (2.0.7) 
Installing activerecord (3.0.3) 
Installing activeresource (3.0.3) 
Installing culerity (0.2.14) 
Installing nokogiri (1.4.4) with native extensions /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/usr/bin/ruby1.8 extconf.rb 
extconf.rb:5:in `require': no such file to load -- mkmf (LoadError)
 from extconf.rb:5


Gem files will remain installed in /home/haoqili/.bundler/tmp/3690/gems/nokogiri-1.4.4 for inspection.
Results logged to /home/haoqili/.bundler/tmp/3690/gems/nokogiri-1.4.4/ext/nokogiri/gem_make.out

 from /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:446:in `each'
 from /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:446:in `build_extensions'
 from /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:198:in `install'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/source.rb:95:in `install'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/installer.rb:55:in `run'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/spec_set.rb:12:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/spec_set.rb:12:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/installer.rb:44:in `run'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/installer.rb:8:in `install'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/cli.rb:225:in `install'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/vendor/thor/task.rb:22:in `send'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/vendor/thor/task.rb:22:in `run'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/vendor/thor.rb:246:in `dispatch'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/vendor/thor/base.rb:389:in `start'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/bin/bundle:13
 from /usr/bin/bundle:19:in `load'
 from /usr/bin/bundle:19
First I tried to fix the mkmf problem by doing
> sudo apt-get install ruby1.9.1-dev
But it gave me the same error. It was solved by installing an older dev version for some reason!
> sudo apt-get install ruby1.8-dev
> sudo gem install nokogiri
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
 ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... no
-----
libxslt is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
 --with-opt-dir
 --without-opt-dir
 --with-opt-include
 --without-opt-include=${opt-dir}/include
 --with-opt-lib
 --without-opt-lib=${opt-dir}/lib
 --with-make-prog
 --without-make-prog
 --srcdir=.
 --curdir
 --ruby=/usr/bin/ruby1.8
 --with-zlib-dir
 --without-zlib-dir
 --with-zlib-include
 --without-zlib-include=${zlib-dir}/include
 --with-zlib-lib
 --without-zlib-lib=${zlib-dir}/lib
 --with-iconv-dir
 --without-iconv-dir
 --with-iconv-include
 --without-iconv-include=${iconv-dir}/include
 --with-iconv-lib
 --without-iconv-lib=${iconv-dir}/lib
 --with-xml2-dir
 --without-xml2-dir
 --with-xml2-include
 --without-xml2-include=${xml2-dir}/include
 --with-xml2-lib
 --without-xml2-lib=${xml2-dir}/lib
 --with-xslt-dir
 --without-xslt-dir
 --with-xslt-include
 --without-xslt-include=${xslt-dir}/include
 --with-xslt-lib
 --without-xslt-lib=${xslt-dir}/lib


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/nokogiri-1.4.4 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/nokogiri-1.4.4/ext/nokogiri/gem_make.out

Thursday, January 27, 2011

Change prompt color (and others) on Linux terminal

Simple way:

> cd ~/
> vim .bashrc
> /force_color_prompt=yes
> delete the "#" in front of this line to uncomment it
> save (":w" in vim)

Open up a new terminal to see results!

----

The more complicated way lets you customize the prompt, you can google it.

Add date to the prompt:
key is adding the :\t: to the line, where you add ":" to separate it from other parts of the prompt. But then it would not be colored.

To add nice colors, wrap it with
:\[\033[01;33m\]\t\[\033[00m\]:

The \[\033[01;33m\] means it's the beginning of the color "33" is yellow in my case, feel free to pick another color. The \[\033[00m\] means you end this coloration.

In the end, I have this:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\t\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Starting Ruby on Rails on Linux

Kinda followed this tutorial. I don't really know what I'm doing here, but I got the Ruby Demo to run.

> sudo apt-get install ruby
> ruby -v
       ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux]
> sudo apt-get install rubygems
> sudo apt-get install rails
> cd demo
> ruby script/server
       => Booting WEBrick
       => Rails 2.3.5 application starting on http://127.0.0.1:3000
       => Call with -d to detach
       => Ctrl-C to shutdown server
       [2011-01-27 03:59:46] INFO  WEBrick 1.3.1
       [2011-01-27 03:59:46] INFO  ruby 1.8.7 (2010-06-23) [i686-linux]
       [2011-01-27 03:59:46] INFO  WEBrick::HTTPServer#start: pid=4587 port=3000

Go to a browser and type in "http://localhost:3000" and you should see:

Hello World! Hello You!

Currently I'm a college senior majoring in Computer Science.  Getting a college degree in Computer Science means almost nothing, since there are so many fun things to learn and explore in this field.  I hope to use this blog as a journal of my progress, as well as a note-keeping tool in case I need to review what I did before or someone else encounters the same problems. In the past few years I have been just emailed notes to myself.  What a complicated mess it created!  This blog will definitely be an upgrade.

A few days ago I upgraded my Ubuntu from 8.04 Hardy Heron to 10.10 Maverick Meerkat. It's very shiny!

If you are a Windows user, I suggest you try Ubuntu.  It's free, easy to use, and safe, since you won't have to worry anymore about getting another virus/worm/scarything from the internet.  Even if you don't use its command line terminal, just using Ubuntu definitely will you lots of awesomeness points.


The End (of this blog)  You should go back to work!