Monday, November 21, 2011

On CoffeeScript, PostgreSQL 8.4 and Subversion

I had installed PostgreSQL 8.4 on my MacBook runnning Lion (10.7.2) for a new project I had started. After this installation my command line svn stopped working with the following error:

dyld: Library not loaded: /usr/lib/libpq.5.dylib
  Referenced from: /usr/bin/svn
  Reason: image not found
Trace/BPT trap: 5

A number of google searches later I was still stuck. Then I noticed that CoffeeScript was now broken as well - I would get the following error when I was building my project:

/usr/local/lib/node_modules/coffee-script/lib/command.js:15
    return process.binding('stdio').writeError(line + '\n');
                   ^
Error: No such module
    at /usr/local/lib/node_modules/coffee-script/lib/command.js:15:20
    at /usr/local/lib/node_modules/coffee-script/lib/command.js:167:7
    at /usr/local/lib/node_modules/coffee-script/lib/command.js:115:26
    at [object Object]. (fs.js:114:5)
    at [object Object].emit (events.js:64:17)
    at afterRead (fs.js:1080:12)
    at Object.wrapper [as oncomplete] (fs.js:252:17)

This was really annoying since much of what I do is writing code, testing code, and then checking it in - when the tools necessary to do two of those steps don't work I can't get much done. Google searches for the CoffeeScript problem also didn't really turn up much except for a messed up NODE_PATH variable. Finally, in an act of desperation I reran "sudo npm install -g coffee-script" and suddenly everything started working again. This fixing the CoffeeScript error I understand - I have no idea how this resolved the svn issue.


UPDATE

So the issue came back and the coffee install trick noted above did not work this time.

A little investigation showed that /usr/lib/libpq.5.dylib was a link pointing to /usr/local/pgsql/lib/libpq.5.dylib which no longer existed. I did notice that /usr/lib/libpq.5.3.dylib was there so I just pointed /usr/local/pgsql/lib/libpq.5.dylib to /usr/lib/libpq.5.3.dylib and svn was working again.

Monday, July 25, 2011

Change hostname in uPortal Quickstart

Quick and dirty - change localhost in the following two files to the server name/IP you want to use:

apache-tomcat-6.0.24/webapps/uPortal/WEB-INF/web.xml
apache-tomcat-6.0.24/webapps/uPortal/WEB-INF/classes/properties/security.properties

This will fix the problem where you deploy the quickstart to a server that is not localhost. The CAS login will now work.

Tuesday, March 22, 2011

Ubuntu 10.10 Black Screen after update and reinstalling NVidia Drivers

So I ran into the situation where I was getting a black screen when gdm should be starting up. I was not able to switch to a different terminal but was able to ssh into the machine. I found the following crash dump in dmesg:

[   13.473227] Pid: 1339, comm: Xorg Tainted: P            2.6.35-28-generic #49-Ubuntu 0RY206/Inspiron 531
[   13.473229] RIP: 0010:[]  [] _nv026788rm+0x44/0x176 [nvidia]
[   13.473529] RSP: 0018:ffff88012a6ddaa8  EFLAGS: 00010282
[   13.473531] RAX: ffff88012a7b0000 RBX: ffff88012a7ba000 RCX: 0000000000000001
[   13.473533] RDX: ffff88012a7b0000 RSI: 0000000000000016 RDI: ffff88012db0e000
[   13.473535] RBP: ffff88012a77df68 R08: ffff88012db20000 R09: ffff88012a7a6800
[   13.473537] R10: 00000000ffffffff R11: 0000000000000077 R12: ffff88012a7be000
[   13.473539] R13: ffff88012db0e000 R14: ffff88012a7b0000 R15: ffff88012e6ae400
[   13.473542] FS:  00007f61416b4840(0000) GS:ffff880001f00000(0000) knlGS:0000000000000000
[   13.473544] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[   13.473546] CR2: ffffffffa0e44082 CR3: 000000012d049000 CR4: 00000000000006e0
[   13.473548] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[   13.473550] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[   13.473553] Process Xorg (pid: 1339, threadinfo ffff88012a6dc000, task ffff88012a6896e0)
[   13.473555] Stack:
[   13.473556]  ffffc90005447000 ffff88012db0e000 ffff88012a77dfe8 ffff88012a7be000
[   13.473559] <0> ffffc90005447000 ffffffffa05d02a2 ffff88012a7b0000 ffff88012e6ae400
[   13.473563] <0> ffff88012db0e000 ffffc90005447000 ffff8801371c3000 ffffffffa05d1259
[   13.473567] Call Trace:
[   13.473875]  [] ? _nv002159rm+0x213/0x256 [nvidia]
[   13.474182]  [] ? _nv002152rm+0x407/0x671 [nvidia]
[   13.474491]  [] ? rm_init_adapter+0x89/0xfd [nvidia]
[   13.474801]  [] ? nv_kern_open+0x5ae/0x760 [nvidia]
[   13.474808]  [] ? chrdev_open+0x10a/0x200
[   13.474811]  [] ? chrdev_open+0x0/0x200
[   13.474815]  [] ? __dentry_open+0xe5/0x330
[   13.474818]  [] ? security_inode_permission+0x1f/0x30
[   13.474822]  [] ? nameidata_to_filp+0x54/0x70
[   13.474825]  [] ? finish_open+0xe8/0x1d0
[   13.474828]  [] ? dput+0xdf/0x1b0
[   13.474831]  [] ? do_last+0x86/0x460
[   13.474834]  [] ? do_filp_open+0x21b/0x660
[   13.474837]  [] ? alloc_fd+0x10a/0x150
[   13.474840]  [] ? do_sys_open+0x69/0x170
[   13.474843]  [] ? sys_open+0x20/0x30
[   13.474847]  [] ? system_call_fastpath+0x16/0x1b
[   13.474849] Code: 00 ba 00 00 00 00 be 3d 00 00 00 41 ff 55 20 48 89 c3 b9 01 00 00 00 ba 00 00 00 00 be 16 00 00 00 4c 89 ef 41 ff 55 20 49 89 c6 <48> 8b 05 13 e0 bd 00 48 89 45 10 8b 05 11 e0 bd 00 89 45 18 0f 
[   13.474874] RIP  [] _nv026788rm+0x44/0x176 [nvidia]
[   13.475172]  RSP 
[   13.475174] CR2: ffffffffa0e44082
[   13.475177] ---[ end trace d0d65b22157fbf8d ]---
[   20.970009] eth0: no IPv6 routers present
[   71.510022] Clocksource tsc unstable (delta = -81563436 ns)

After quite a bit of searching without any luck I tried to remember what I had done prior. This had actually happened previously and I ended up reinstalling Ubuntu to fix the problem. It was very disheartening when it happened again. I did recall that it had started happening shortly after I had setup this computer for dev work on Chromium. This problem had also started occurring after setting up to work on Chromium. One of the more invasive packages that I had installed is the gold replacement ld. Since part of the NVidia drivers involves building (I assume) kernel modules I thought this might be part of the problem - AND IT WAS! :-)

For now I just uninstalled binutils-gold, reinstalled the NVidia driver, and now X is starting up just fine.

Hope this helps someone else out there.

Sunday, March 13, 2011

Exclude svn files and directories from grep

# Set default grep options to ignore svn files and directories
export GREP_OPTIONS="--exclude=*\.svn* --exclude-dir=\.svn"

Saturday, March 12, 2011

grep -R IDR_PDF_BUTTON_FTH *

out/Debug/obj/gen/webkit/grit/webkit_resources.h:#define IDR_PDF_BUTTON_FTH 4544
out/Debug/obj/gen/webkit/grit/webkit_resources.h:#define IDR_PDF_BUTTON_FTH_HOVER 4545
out/Debug/obj/gen/webkit/grit/webkit_resources.h:#define IDR_PDF_BUTTON_FTH_PRESSED 4546
webkit/glue/.svn/text-base/webkit_resources.grd.svn-base:      
webkit/glue/.svn/text-base/webkit_resources.grd.svn-base:      
webkit/glue/.svn/text-base/webkit_resources.grd.svn-base:      
webkit/glue/webkit_resources.grd:      
webkit/glue/webkit_resources.grd:      
webkit/glue/webkit_resources.grd:      
webkit/plugins/ppapi/.svn/text-base/ppb_pdf_impl.cc.svn-base:  { PP_RESOURCEIMAGE_PDF_BUTTON_FTH, IDR_PDF_BUTTON_FTH },
webkit/plugins/ppapi/.svn/text-base/ppb_pdf_impl.cc.svn-base:  { PP_RESOURCEIMAGE_PDF_BUTTON_FTH_HOVER, IDR_PDF_BUTTON_FTH_HOVER },
webkit/plugins/ppapi/.svn/text-base/ppb_pdf_impl.cc.svn-base:  { PP_RESOURCEIMAGE_PDF_BUTTON_FTH_PRESSED, IDR_PDF_BUTTON_FTH_PRESSED },
webkit/plugins/ppapi/ppb_pdf_impl.cc:  { PP_RESOURCEIMAGE_PDF_BUTTON_FTH, IDR_PDF_BUTTON_FTH },
webkit/plugins/ppapi/ppb_pdf_impl.cc:  { PP_RESOURCEIMAGE_PDF_BUTTON_FTH_HOVER, IDR_PDF_BUTTON_FTH_HOVER },
webkit/plugins/ppapi/ppb_pdf_impl.cc:  { PP_RESOURCEIMAGE_PDF_BUTTON_FTH_PRESSED, IDR_PDF_BUTTON_FTH_PRESSED },

grep -R pdf_button_fth *

webkit/glue/.svn/text-base/webkit_resources.grd.svn-base:      
webkit/glue/.svn/text-base/webkit_resources.grd.svn-base:      
webkit/glue/.svn/text-base/webkit_resources.grd.svn-base:      
webkit/glue/resources/.svn/entries:pdf_button_fth.png
webkit/glue/resources/.svn/entries:pdf_button_fth_pressed.png
webkit/glue/resources/.svn/entries:pdf_button_fth_hover.png
webkit/glue/resources/.svn/all-wcprops:pdf_button_fth.png
webkit/glue/resources/.svn/all-wcprops:/svn/!svn/ver/59150/trunk/src/webkit/glue/resources/pdf_button_fth.png
webkit/glue/resources/.svn/all-wcprops:pdf_button_fth_pressed.png
webkit/glue/resources/.svn/all-wcprops:/svn/!svn/ver/59150/trunk/src/webkit/glue/resources/pdf_button_fth_pressed.png
webkit/glue/resources/.svn/all-wcprops:pdf_button_fth_hover.png
webkit/glue/resources/.svn/all-wcprops:/svn/!svn/ver/59150/trunk/src/webkit/glue/resources/pdf_button_fth_hover.png
webkit/glue/webkit_resources.grd:      
webkit/glue/webkit_resources.grd:      
webkit/glue/webkit_resources.grd:      

Sunday, February 13, 2011

Spreenkler Talent Labs Hackathon

Saturday was the Spreenkler Talent Labs Hackathon.

I worked with Juba and Wei on ReMa (live site until I need the google app instance for something else, repo).  From the README I checked in the morning after the hackathon:

ReMa is a social community resource management website that was worked on for the Spreenkler Talent Labs hackathon on 2011/2/12.
The basic idea was a site where members of a community could go and post:
 - Things they need
 - Services they need done / helped with
 - Things they have
 - Services they can offer
The basic idea is to help the community with resources and services the community already has. This is accompolished through each member sharing this information on an easy to use website. We had something working by the end of the hackathon but it still needs alot more polish.

I had a great time - I have not worked that hard on a project since Senior Design. Some take away notes for us:

  • Need someone to concentrate more on the business development side next time - no prep for the presentation and had not really come up with much of a business case. Juba did have a decent idea of making use of our tags for contextual ads.
  • Prior to the event, we need to spend a couple of days in the tech stack that we would be using. Juba and I had not had a chance to do much GAE stuff in the weeks leading up and it took a little bit to get back into the swing.
  • Disregard everything not core to the product (user auth for example - Juba and I spent too much time getting that "working")
Congrats to the winners: 1000 Eyes (not sure if they have a live site yet but will add link if I come across it)

Saturday, January 22, 2011

405 Error on Google App Engine

I was happily programming away on a new project on Google App Engine when I started getting 405 errors from all of my handlers. I would get the following in the dev app server log:

dev_appserver.py:3317] "GET / HTTP/1.1" 405 -

In the Firebug:

URL                   Status                
> GET localhost:8084  405 Method Not Allowed

In the browser when I tried to directly access pages they would render normally but if you looked at the headers I was still getting the 405 error and anything Ajax would fail. From looking around Google and StackOverflow there seemed to be a various reasons for this to fail, none of which seemed to be my issue.

What eventually turned out to be the issue was that I was trying to be a good OOP programmer and was calling up the inheritance tree for each of my methods. So HomeHandler.get() was calling BaseHandler.get() was calling webapp.RequestHandler.get(). Unfortunately, it seems that webapp.RequestHandler.get() does not exist or is at least not callable which resulted in the 405 status code. I changed my BaseHandler.get to not call webapp.RequestHandler.get and we were back in business.

Hopefull this blog post saves you some time.

Modeling collections in Google App Engine

When I first began working with Google App Engine I assumed I would need to model a one-to-many relationship manually with a db.ReferenceProperty in each of the manies and db.ListProperty(db.ReferenceProperty) on the one. The actual solution is much simpler and elegant:

class StackUserData(db.Model):
    name = db.StringProperty()
    last_access = db.IntegerProperty()

class Activity(db.Model):
    user = db.ReferenceProperty(StackUserData,
                                collection_name='activities')
    title = db.StringProperty()
    body = db.StringProperty(default='')
    link = db.LinkProperty()
    creation_date = db.IntegerProperty()
    last_activity_date = db.IntegerProperty()

This adds an activities attribute to StackUserData behind the scenes. So StackUserData.activities will give you a list of all activities owned by that StackUserData instance. This relationship is set when creating the Activity:

Activity(user = activity_owner_user).put()

This code will create a new Activity and attach it to the activity_owner_user.

Find out more at Datastore series: Modeling Entity Relationships

Monday, January 17, 2011

Aero Snap Keyboard Shortcuts in Ubuntu

I wanted the "Aero Snap" functionality in Windows 7 to work on my fresh Ubuntu 10.10 install. In case you are not familiar, this allows a window to snap to a certain position. I have a widescreen monitor that is wide enough to comfortably have two windows side by side. Arranging this by hand is a pain. The snap feature will automatically resize a window to maximum vertical and half the width of the screen on either side. In Windows 7 you can either drag the window to the sides of the desktop or you can use the Windows key + arrows shortcuts. I was mostly interested in the shortcuts.

I found the basic solution at Get Aero Snap in Ubuntu

The instructions as given did not quite work for me so I just hardcoded in the width of my screen:

WIDTH=1920 && HALF=$(($WIDTH/2)) && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-1
WIDTH=1920 && HALF=$(($WIDTH/2)) && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$HALF,0,$HALF,-1
wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz

Note that I did not need to change the last entry for going full screen. Then under the General Options of the Compiz Settings Manager I just mapped Key Bindings rather than Edge Bindings.

Command 0 to Windows Key + Left Arrow
Command 1 to Windows Key + Right Arrow
Command 2 to Windows Key + Up Arrow

Sunday, January 16, 2011

Problems compiling Chromium with distcc

So everything appeared to be working, however, I am getting compile errors when using distcc that I am not getting when I only compile locally. Will investigate more...stay tuned.

Thursday, January 13, 2011

Using distcc to build Chromium with mix of 32 and 64 bit machines

I have been wanting to hack on Chromium for a while and have finally found the time to download the source and try building it. The first build on my main desktop took quite a while so I thought I would also take the opportunity to try out distcc, incorporating an older laptop that I had lying around as well as my new netbook. The desktop and netbook are both 64 bit and the older laptop is an i686.

All the machines are running Ubuntu 10.10, netbook and desktop running the 64 bit build. On the i686 I installed the multilibs package (see previous post).

I was initiating the build from the 64bit desktop. Since this system was already a 64 bit system it would compile 64 bit by default. However, the 32 machine would compile only 32 bit by default. To fix this problem, I needed to explicitly set the flags for generating the 64 bit executables. So on the 64 bit system I set CFLAGS and CXXFLAGS to -m64.

I wish it had actually been as easy as this post may lead you to believe it was but I spent a couple of days on this and asked one question on Stack Overflow.

Sunday, January 9, 2011

Cross compiling 64 bit program on 32 bit machine (Ubuntu 10.10)

In preparation for creating a small build cluster for helping with compiling Chromium I was trying to get my old college laptop up and running under Ubuntu 10.10. I installed the g++-multilib package as multiple sources on the internet had instructed but when I tried compiling 64 bit hello world I got the following error:
In file included from main.cpp:1:
/usr/include/c++/4.4/iostream:39: fatal error: bits/c++config.h: No such file or directory
compilation terminated.
Searching through /usr/include yielded a couple instances of bits/c++config.h but they were all located under different architectures (i486-linux-gnu, i686-linux-gnu).

Googling around did not result in much so I decided to ask the fine folks over at Stackoverflow (link to question is at bottom of page - if you read it now, this post will be significantly less interesting). One answer told me to explicitly include the path for the c++config.h file from the other architectures - this worked but it seemed a bit hacky to have to explicitly set include paths for system includes.

I had not used the verbose parameter for g++ before so I thought I would give it a try to see if that could explain a little more what the system was trying to do:
jesse@shalored:~/projects/test$ g++ -v -m64 main.cpp
Using built-in specs.
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)
COLLECT_GCC_OPTIONS='-v' '-m64' '-shared-libgcc' '-mtune=generic'
/usr/lib/gcc/i686-linux-gnu/4.4.5/cc1plus -quiet -v -imultilib 64 -D_GNU_SOURCE main.cpp -D_FORTIFY_SOURCE=2 -quiet -dumpbase main.cpp -m64 -mtune=generic -auxbase main -version -fstack-protector -o /tmp/ccMvIfFH.s
ignoring nonexistent directory "/usr/include/c++/4.4/i686-linux-gnu/64"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../i686-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.4
/usr/include/c++/4.4/backward
/usr/local/include
/usr/lib/gcc/i686-linux-gnu/4.4.5/include
/usr/lib/gcc/i686-linux-gnu/4.4.5/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
GNU C++ (Ubuntu/Linaro 4.4.4-14ubuntu5) version 4.4.5 (i686-linux-gnu)
compiled by GNU C version 4.4.5, GMP version 4.3.2, MPFR version 3.0.0-p3.
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128197
Compiler executable checksum: 1fe36891f4a5f71e4a498e712867261c
In file included from main.cpp:1:
/usr/include/c++/4.4/iostream:39: fatal error: bits/c++config.h: No such file or directory
compilation terminated.
The ignoring nonexistent directory error messages was what gave me the clue. Since it was looking for /usr/include/c++/4.4/i686-linux-gnu/64, I checked my 64 machine hoping to see a similiar structure but with an x86_64 architecture and corresponding 32bit directory. Sure enough it was there: /usr/include/c++/4.4/x86_64-linux-gnu/32/bits. To fix my problem I just copied the /usr/include/c++/4.4/x86_64-linux-gnu/bits directory from my 64 bit machine to /usr/include/c++/4.4/i686-linux-gnu/64/bits on my 32 machine.

Now I know this is not a proper solution since the next update to the system could break something but I think it was enough to get going. Now on to getting this system to help out with building!

Stackoverflow Question: Missing include “bits/c++config.h” when cross compiling 64 bit program on 32 bit in Ubuntu