Showing posts with label annoying. Show all posts
Showing posts with label annoying. Show all posts

Sunday, April 14, 2013

Mounting Stanford AFS Ubuntu

Stanford uses AFS to host filesystem space for students. Stanford also uses Kerberos for authentication. The combination of the two can be maddening to work with remotely.

These directions are to for people with running Ubuntu who would like to mount the Stanford afs to access files as if they were local. Restating 1nfty's directions:
  1. Install kerberos and afs related components
    sudo apt-get install krb5-user krb5-clients openafs-krb5 openafs-client
  2. Make sure /afs exists. If not, create it.
  3. Reboot to find /afs directory filled with pointers to afs volumes all over the world.
  4. Authenticate through kerberos and obtain AFS token by sequentially running
    kinit
    aklog
  5. Make soft link of your user directory to somewhere more convenient
    ln -s /afs/ir.stanford.edu/[path_to_afs_home_directory] ~/afs
These directions did not work straight out of the box for me. I'm pretty sure Narasimham's directions were all I needed, but I'm not sure. Stanford's directions were pretty bloated and I couldn't make much sense of them. If(When) I have to go through the procedure again, then I'll more thoroughly document the procedure and clean this post up.

Once everything is all set up, don't forget to authenticate before actually trying to access your files:
kinit
aklog


Tuesday, March 5, 2013

g++ compiler options

Four stages of creating a program
  1. Preprocess
  2. Compile
  3. Assemble
  4. Link
Example: Creating and using a shared library (lib*.so - filename starts with prefix "lib" and ends with suffix ".so"):
First, we'll create the object file from the source.
g++ -c <filename.cpp> -o <filename.o>
-c specifies that we're only compiling, not linking. We do this when filename.cpp doesn't have a main function so there's nothing to link.
-o specifies the output file name. Note that it doesn't have to end in .o, but the .o ending is convention for object file
Next, we'll create the shared object file library from the object file
g++ -shared -fPIC <filename.o> -o <libfilename.so>
-shared indicates that we're creating a shared library
-fPIC indicates that we're creating position independent code.
Excellent, we've now created a shared library!

Now for the fun part, linking, the biggest headache of them all. Let's say we wan't to use the library in <appname.cpp>.
g++ <appname.cpp> -L. -l<filename> -Wl,-rpath,. -o <appname>
-L. tells the g++ to look in the current directory (hence the ".") at link-time for the library.
-l<filename> tells which library we'll be using (Although the library will look something like lib<filename>.so, the convntion is -l<filename>).
-Wl,<ld option> passes <option> to the linker. <option> can be comma separated for multiple options as we do. By passing "-rpath,." to the linker, we tell it to use the current directory "." at run-time linking. Note the separation of link-time and run-time paths when looking for libraries.

Putting it all together looks something like

g++ -c <filename.cpp> -o <filename.o>
g++ -shared -fPIC <filename.o> -o <libfilename.so>
g++ <appname.cpp> -L. -l<filename> -Wl,-rpath,. -o <appname>



Sunday, February 3, 2013

Adding printer, Ubuntu 12.04

Adding a printer is one of the most annoying tasks I've dealt with.  It doesn't help that there are dozens of printing protocols and ways to connect to a printer. Here is a step-by-step to remind myself of this process.
  1. From terminal, run sudo system-config-printer
  2. In the dialog box that opens, press Add
  3. Enter the device URI
    • e.g. socket://172.25.102.32
  4. It'll ask for a driver, you can see if it's available from the drop down menus but this is unlikely from my experience. Usually, you'll just have to find and provide the .ppd file yourself.
  5. Accept the installable options and device name etc...
  6. print a test page! Hopefully it works. If not, get angry and continue your quest across the internets.
Happy printing! 
(I'm going to hate myself for the cheery ending when this doesn't work)