28 July 2014

586.Very Briefly: Gnuradio, RTL-SDR, GQRX and an R280T device on debian jessie

NOTE:
* I did this on debian jessie which at the time has gnuradio v 3.7.3-9+b1 and rtl-sdr v 0.5.3-3

* I'm having a lot of trouble getting gqrx working on debian wheezy even with backports. Whereas the backports versions of gnuradio, rtl-sdr and gqrx-sdr install just fine, when running gqrx I get the following error:
gqrx: symbol lookup error: /usr/lib/x86_64-linux-gnu/libQtNetwork.so.4: undefined symbol: _ZN16QIODevicePrivate13putCharHelperEc
* gqrx won't work on debian wheezy systems with 2 Gb of memory for some reason. I get the same error as is shown in this post: https://groups.google.com/forum/#!topic/gqrx/20F8RMWkNbU

The post:
I recently bought a DVB USB dongle based on RTL2832 and R280T: http://www.ebay.com.au/itm/221450623699?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649. AU$11for a TV card which actually works flawlessly under linux really isn't bad!

As I already have a mythtv setup using leadtek DTV 1000S I was more interested in exploring the R820T dongle as a software defined radio (SDR).

 So, after glancing at  http://www.thepowerbase.com/2012/06/getting-started-with-rtl-sdr/2/ I did the following


sudo apt-get install rtl-sdr gnuradio gnuradio-dev libgnuradio-osmosdr0.1.1.4 git libboost-dev liblog4cpp5-dev libboost-system-dev libboost-program-options-dev checkinstall
mkdir ~/tmp
cd ~/tmp
git clone https://github.com/csete/gqrx.git gqrx.git
cd gqrx.git/
mkdir build
cd build
qmake ../
make
sudo checkinstall --install=no
0 - Maintainer: [ root@niobium ] 1 - Summary: [ gqrx ] 2 - Name: [ gqrx ] 3 - Version: [ 20140726 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ amd64 ] 8 - Source location: [ build ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ build ] 12 - Conflicts: [ ] 13 - Replaces: [ ]
sudo dpkg -i gqrx_20140726-1_amd64.deb

Starting gqrx and using it is easy:
gqrx
So far I haven't managed to get anything other than regular commercial radio signals (I've only explored the FM band).

17 July 2014

585. Very briefly: use latex to combine .eps files into a single .eps

Say you have a figure made up by several smaller images by combining several includegraphics statements. Say also that you need to submit the figure as a single file when uploading the final version of your article.

The first step is to make sure that the output .ps file fits flush to the figure (see http://texblog.org/tag/fit-page-to-content/) using the standalone class:
 
\documentclass[varwidth=true, border=10pt, convert={size=640x}]{standalone} \usepackage[english]{babel} \usepackage{graphicx} \begin{document} \begin{figure}[h] \begin{center} \includegraphics[width=2.0cm]{figure_1a.eps} \includegraphics[width=2.0cm]{figure_1b.eps} \includegraphics[width=2.0cm]{figure_1c.eps} \\ \includegraphics[width=2.0cm]{figure_1d.eps} \includegraphics[width=2.0cm]{figure_1e.eps} \end{center} \end{figure} \end{document}
Then use ps2eps to turn the ps into an eps file:

ps2eps combined_image.ps

24 June 2014

584. Build your own pH meter (analogue)

A few years ago a friend of mine with a degree in engineering helped me build a simple pH meter. In terms of quality of the readings there is no difference between it and our $15,000 titrino.

Either way, I'm putting the description of it online here in case other people are interested. Note that 'we' designed it based on what we found available from various websites, so the design is hardly unique.

Also note that it requires a multimeter/voltmeter to get a reading -- there's no USB/serial output or anything fancy like that.

(in related news I'm planning on taking night classes in electronics at a local TAFE (which is like a community college) so that I can start building more instruments/toys myself. A potentiostat would be nice...)

Anyway, back when we built this we ordered the parts from Digikey (I lived in the US at the time), and here's a list of what we got as shown on the invoice (the parts numbers of the linked items differ in some cases -- I presume that they are the same, but cannot guarantee that they are.
* Note that you'll need more than one of some items.
* Note that the parts includes stuff for using a whiteboard/prototyping board i.e. we first made a non-soldiered version, and then made a permanent assembly. 
* The stuff for the final pH meter (i.e. the stuff in the pomona box) is shown in red
* The stuff for connection the pH meter to a voltmeter/multimeter is shown in blue
* The stuff that's needed for the power supply is in bold black
* Stuff that I ordered at the same time but can't remember what we used it for is in the default colour (i.e. black)

Price     Item number               Description       
(USD)    (Digikey)
---------     ---------------------                --------------------      
3.05       LMC6081IN-ND      IC OP AMP PREC CMOS SINGLE 8-DIP  
2.96       ACX1046-ND          Conn. enc. bulkhead female jack x 2
3.78       7-1437529-5-ND     Conn socket dip 8 pos gold T/h

7.71       J6212-ND               BNC cable        

8.07       501-1032-NB          BNC female-dbl banana
47.85     945-1081-ND          Converter AC/DC 15W +/-12V out DL T/H


In addition, looking at the board (see pictures below), you'll also need
3 x female banana sockets
2 x K5M104(?) capacitor (x 2)
2 x BC1020TR-ND BC102 capacitor (x 2)
3 x female banana sockets
and lots of wires.


You'll measure the potential (emf) using a voltmeter, and by calibrating  the potential against a set of pH standards you can calculate the pH. In theory 0.0 mV should be at pH 7, and the potential should increase ca 59 mV per pH unit, so that pH 6 is +59 mV and pH 8 is -59 mV.

Whether this is actually true (it won't be) depends on your pH electrode, temperature, ionic strength etc.

pH box:
Add caption

Annotated view








The BNC cable is connected to a double banana contact, which attaches to the voltmeter


Power supply:
You can get a proper one, or build one yourself. I did the latter. It ain't pretty -- in fact, the following pictures should horrify you. NOTE: unless you know what you are doing you MIGHT DIE! Playing with high voltage stuff may also be ILLEGAL for unlicensed people in some jurisdictions.


Power OUT -- +12 and -12 V, and ground.

Power IN

Green goes from Ground IN to the ground pin on the right on the power supply. The thin yellow wire then goes to the ground pin on the left on the power supply. The fat yellow wire then goes to the ground out banana plug. If your ground touches ANY of the other pins you may ELECTROCUTE yourself.


583. Very, very briefly: using a USB graphics card with a headless box

This is an 'It Works' post. No tips or tricks, simply a report of something that works out of the box.

I've got a tiny server which has the following ports:
2 x USB type A, 4 x RJ45/8P8C (eth), 1x DE-9 (RS-232). There's no VGA out.

While this isn't a real problem -- I normally install linux on it either via a chroot or via a virtual machine by hooking up the HDD via a HDD-> USB cable to another computer -- it would be nice to be able to hook up a monitor to the server, in particular as I'm thinking about turning it into a lab computer to use for measurements. That it's so portable (21 x 15 x 4 cm) is an added bonus as it allows us to move it between labs.

Anyway, I bought an FY-1650  USB-to-VGA card (see e.g. here and here) for ca AUD 37 on ebay:

lsusb gives 
Bus 001 Device 003: ID 17e9:019e DisplayLink


I currently run debian wheezy (i386) on the server. Plugging in the card and a monitor and booting up everything worked without needing to do anything.

NOTE: by working I mean that I get the terminal -- I haven't tried this with a full desktop environment such as gnome, xfce etc.

Very happy...


13 June 2014

582. Briefly: freecall.com using linphone

I've covered how to set up linphone in the past: http://verahill.blogspot.com.au/2011/08/linphone-with-iinet-iitalk-voip-service.html

This is thus going to be a very brief post with just the settings for freecall.com, which offers a SIP service.

The specific settings that you need to make are (this is from my ~/.linphonerc
[auth_info_0] username=myUserId userid=myUserId passwd=PasswordInPlainText realm="sip.freecall.com" [proxy_0] reg_proxy=sip:sip.freecall.com reg_identity=sip:myUserID@sip.freecall.com reg_expires=3600 reg_sendregister=1 publish=0 dial_escape_plus=0

Yes, that's it. So, there you go - you now have a reasonably priced alternative to Skype for international calling.

I've charged my account with 10 Euro, and I've made a few test phone calls. So far so good.

See http://verahill.blogspot.com.au/2014/06/581-obi200-and-debian-and-iinet.html for how to use the obihai 200 ATA with freecall.

12 June 2014

581. Obihai Obi200 ATA and iinet Australia (and freecall)

I've had iitalk sip service as part of my naked DSL via iinet for years, but haven't really done much with it (apart from writing a post: http://verahill.blogspot.com.au/2011/08/linphone-with-iinet-iitalk-voip-service.html). I decided that it might be time to get something akin to a landline, and if it involves buying a new toy, so much better. The toy in question is an ATA device, which allows you to connect your regular old landline phone to your fancy internet router.

I ordered an Obihai OBI200 from Amazon US and had it delivered to Australia.

Getting started was pretty straightforward:
I unpacked the device, plugged in the power cable, and hooked it up to my router via an ethernet cable. I then gave it a static IP address, 192.168.2.131

Next I registered on the obitalk.com website, confirmed my email address, and logged in. You're then offered to set up your device. Note that you'll need to have a phone plugged into your obi device at this point. I bought a $32 Panasonic KX-TG1611 from JB HiFi.

Anyway, go to http://www.obitalk.com




go to dashboard

click on SP1

click on Next in the bottom right


select Generic Service Provider
The settings are as follows:
(state=vic, nsw etc. i.e. three-letter code)
Service Provider Proxy Server: sip.state.iinet.net.au
Service Provider Proxy Server port: 5060
Outbound Proxy Server: sip.state.iinet.net.au
Outbound Provider Proxy Server port: 5060
User Name: your phone number (e.g. 03 xxxx xxxx; look it up on your iinet toolbox)
Password: your VOIP password which you set up at some point
URI: yourphonenumber@sip.state.iinet.net.au

Hit submit

If all went well you'll show up as being registered.


freecall.com
I'm thinking about replacing skype with sip, and one provider is freecall.com. I originally signed up with them many years ago because I got a free number, but my account has expired, and they won't let me reactivate it. Either way,  you can still call pretty cheaply using their service.

The settings for the OBI200 and freecall are:
Service Provider Proxy Server: sip.freecall.com
Outbound Proxy Server: sip.freecall.com
User Name: your user name
Password: your password
URI: yourusername@freecall.com

I will work on setting it up for international calls at a later stage.

To select a specific service when making a call, type **1 for SP1, **2 for SP2 etc. See http://www.obihai.com/faq/About-the-OBi/How-do-I-make-calls-with-OBi

10 June 2014

580. Python script: Interpolate between structures in a multi-xyz file

I'm doing a lot of NEB (nudged elastic band) calculations using nwchem at the moment, and while getting 'neb convergence' is simple enough, I often get an error along the lines of
3965547 @neb NEB calculation converged
3965548 @neb However NEB Gmax not converged...Try increasing the number of beads.

While that sounds simple enough it's nicer if you don't have to go back to the beginning and e.g. run a more fine-grained PES job to generate a reasonable trajectory (straight linear interpolation often doesn't work), then keep on running neb iterations. One way to cut down on time (presumably) is to simply pad the neb path xyz with intermediate structures, and that is what this python (2.7) script does.

Oh, and I really wish blogspot would support code inclusion better...

How to use:
python nebinterpolate.py -i neb_A_F.neb_final.xyz  -o test.xyz

Example:
Say we have the structure of methanol, and methanol in which the oxygen-carbon distance is 3.0 Ångström:

Here's the corresponding xyz file, which we'll call first.xyz:
6 C 0.03517 0.00549 0.03517 H -0.61778 -0.63407 0.66798 H 0.66798 -0.63407 -0.61778 H -0.60514 0.64647 -0.60514 O 0.83960 0.81877 0.83960 H 1.38912 0.20156 1.38912 6 C 0.03517 0.00549 0.03517 H -0.61778 -0.63407 0.66798 H 0.66798 -0.63407 -0.61778 H -0.60514 0.64647 -0.60514 O 1.76087 1.75017 1.76087 H 2.31039 1.13296 2.31039

Run nebinterpolate -i first.xyz -o second.xyz and you'll get a new xyz file with three structures -- the first one plus an intermediate structure:

Here's the new file, second.xyz:
6 C 0.03517 0.00549 0.03517 H -0.61778 -0.63407 0.66798 H 0.66798 -0.63407 -0.61778 H -0.60514 0.64647 -0.60514 O 0.83960 0.81877 0.83960 H 1.38912 0.20156 1.38912 6 structure 2 C 0.03517 0.00549 0.03517 H -0.61778 -0.63407 0.66798 H 0.66798 -0.63407 -0.61778 H -0.60514 0.64647 -0.60514 O 1.30024 1.28447 1.30024 H 1.84976 0.66726 1.84976 6 C 0.03517 0.00549 0.03517 H -0.61778 -0.63407 0.66798 H 0.66798 -0.63407 -0.61778 H -0.60514 0.64647 -0.60514 O 1.76087 1.75017 1.76087 H 2.31039 1.13296 2.31039

 Run it again, nebinterpolate -i second.xyz -o third.xyz, and you'll get:

Here's the new file, third.xyz:
6 C 0.03517 0.00549 0.03517 H -0.61778 -0.63407 0.66798 H 0.66798 -0.63407 -0.61778 H -0.60514 0.64647 -0.60514 O 0.83960 0.81877 0.83960 H 1.38912 0.20156 1.38912 6 structure 2 C 0.03517 0.00549 0.03517 H -0.61778 -0.63407 0.66798 H 0.66798 -0.63407 -0.61778 H -0.60514 0.64647 -0.60514 O 1.06992 1.05162 1.06992 H 1.61944 0.43441 1.61944 6 structure 2 C 0.03517 0.00549 0.03517 H -0.61778 -0.63407 0.66798 H 0.66798 -0.63407 -0.61778 H -0.60514 0.64647 -0.60514 O 1.30024 1.28447 1.30024 H 1.84976 0.66726 1.84976 6 structure 4 C 0.03517 0.00549 0.03517 H -0.61778 -0.63407 0.66798 H 0.66798 -0.63407 -0.61778 H -0.60514 0.64647 -0.60514 O 1.53056 1.51732 1.53056 H 2.08007 0.90011 2.08007 6 C 0.03517 0.00549 0.03517 H -0.61778 -0.63407 0.66798 H 0.66798 -0.63407 -0.61778 H -0.60514 0.64647 -0.60514 O 1.76087 1.75017 1.76087 H 2.31039 1.13296 2.31039

Now, the real use for this is when you've been optimising a string of structures using NEB and want to increase the number of images because you're not getting gmax convergence, or if you want to do a quick and rough optimisation and then get a prettier looking set of coordinates.

You can load the multi-xyz file in nwchem by using

NEB
   ...
  XYZ_PATH path.xyz
END


nebinterpolate.py 

#!/usr/bin/python

import sys

def getvars(arguments):
 switches={}

 version='0.1'
 
 try:
  if "-i" in arguments:
   switches['in_one']=arguments[arguments.index('-i')+1]
   print 'Input: %s '% (switches['in_one'])
  else:
   arguments="--help";
 except:
  arguments="--help";
  
 try:
  if "-o" in arguments:
   switches['o']=arguments[arguments.index('-o')+1].lower()
   print 'Output: %s'% switches['o']
  else:
   arguments="--help";
 except:
  arguments="--help";

 try:
  if "-w" in arguments:
   switches['w']=float(arguments[arguments.index('-w')+1])
   print 'Weighting: %i'% switches['w']
  else:
   print 'Assuming no weighting'
   switches['w']=1.0;
 except:
  switches['w']=1.0;

 doexit=0
 try:
  if ("-h" in arguments) or ("--help" in arguments):
   print '\t\t bytes2words version %s' % version
   print 'Creates interpolated structures'
   print 'from an multixyz file'
   print '--input \t-i\t multi-xyz file to morph'
   print '--output\t-o\t output file'
   print '--weight\t-w\t weight first structure vs second one (1=average; 0=start; 2=end)'
   print 'Exiting'
   doexit=1
 except:
  a=0 # do nothing
 if doexit==1:
  sys.exit(0)

 return switches

def getcmpds(switches):
 
 cmpds={}
 
 g=open(switches['in_one'],'r') 
 n=0
 xyz=[]
 atoms=[]
 structure_id=1

 for line in g:

  try:
   if len(xyz)==cmpds['atoms_'+str(structure_id)]:
    cmpds['coords_'+str(structure_id)]=xyz
    cmpds['elements_'+str(structure_id)]=atoms   
    structure_id+=2
    n=0
    atoms=[]
    xyz=[]
  except:
   pass

  n+=1
  line=line.rstrip('\n')
   
  if n==1:
   cmpds['atoms_'+str(structure_id)]=int(line)
  elif n==2:
   cmpds['title_'+str(structure_id)]=line
  else:
   line=line.split(' ')
   line=filter(None,line)
   xyz+=[[float(line[1]),float(line[2]),float(line[3])]]
   atoms+=[line[0].capitalize()]
 g.close

 cmpds['coords_'+str(structure_id)]=xyz
 cmpds['elements_'+str(structure_id)]=atoms   
 cmpds['w']=switches['w']
 cmpds['structures']=(structure_id)
 
 return cmpds

def morph(cmpds,structure_id):
 coords_one=cmpds['coords_'+str(structure_id)]
 coords_two=cmpds['coords_'+str(structure_id+2)]
 
 coords_morph=[]
 coords_diff=[]
 for n in range(0,cmpds['atoms_'+str(structure_id)]):
  morph_x=coords_one[n][0]+cmpds['w']*(coords_two[n][0]-coords_one[n][0])/2.0
  morph_y=coords_one[n][1]+cmpds['w']*(coords_two[n][1]-coords_one[n][1])/2.0
  morph_z=coords_one[n][2]+cmpds['w']*(coords_two[n][2]-coords_one[n][2])/2.0
  diff_x=coords_two[n][0]-coords_one[n][0]
  diff_y=coords_two[n][1]-coords_one[n][1]
  diff_z=coords_two[n][2]-coords_one[n][2]
  coords_morph+=[[morph_x,morph_y,morph_z]]
  coords_diff+=[[diff_x,diff_y,diff_z]]

 cmpds['atoms_'+str(structure_id+1)]=cmpds['atoms_'+str(structure_id)]
 cmpds['elements_'+str(structure_id+1)]=cmpds['elements_'+str(structure_id)]
 cmpds['title_'+str(structure_id+1)]='structure '+str(structure_id+1)
 cmpds['coords_'+str(structure_id+1)]=coords_morph

 return cmpds

def genxyzstring(coords,element):
 x_str='%10.5f'% coords[0]
 y_str='%10.5f'% coords[1]
 z_str='%10.5f'% coords[2]
 
 xyz_string=element+(3-len(element))*' '+10*' '+\
 (8-len(x_str))*' '+x_str+10*' '+(8-len(y_str))*' '+y_str+10*' '+(8-len(z_str))*' '+z_str+'\n'
 
 return xyz_string

def writemorph(cmpds,outfile):
 g=open(outfile,'w') 

 for m in range(1,cmpds['structures']+1):
  g.write(str(cmpds['atoms_'+str(m)])+'\n')
  g.write(str(cmpds['title_'+str(m)])+'\n')
  for n in range(0,cmpds['atoms_'+str(m)]):
   coords=cmpds['coords_'+str(m)][n]
   g.write(genxyzstring(coords, cmpds['elements_'+str(m)][n]))
 g.close

 return 0

if __name__=="__main__":
 arguments=sys.argv[1:len(sys.argv)]
 switches=getvars(arguments)
 cmpds=getcmpds(switches)

#check that the structures are compatible
 for n in range(1,cmpds['structures'],2):

  if cmpds['atoms_'+str(n)]!=cmpds['atoms_'+str(n+2)]:
   print 'The number of atoms differ. Exiting'
   sys.exit(1)
  elif cmpds['elements_'+str(n)]!=cmpds['elements_'+str(n+2)]:
   print 'The types of atoms differ. Exiting'
   sys.exit(1)
  cmpds=morph(cmpds,n)
 success=writemorph(cmpds,switches['o'])
 if success==0:
  print 'Conversion seems successful'

29 May 2014

579. TEMPerHum (0c45:7402 ) on debian linux wheezy

Yet another little usb device from PC sensors (I seem to have been giving them a fair amount of money recently ).

This is the device in question: http://pcsensor.com/index.php?_a=product&product_id=178 (note that I buy my devices via ebay where the prices are apparently always the campaign ones -- I paid AUD25 , not USD80)

It didn't come in a box so I have no scans or shots to show.

[See here for the regular TEMPer USB device (0c45:7401), and here for the TEMPer 1K4  (0c45:7403) USB thermocouple reader. Note that since the temper-usb code is in  a lot of flux you can't use the line numbers in those posts directly -- you'll have to read and understand the code before pasting it in. Luckily, it's quite simple -- even I managed to sort it out!]

I couldn't get temper-usb to work even when making (what I consider) the necessary edits, but instead got lots of errors (including " usb.USBError: could not detach kernel driver from interface 1: No data available"). So I finally gave up.

Instead, web searching led me to http://edorfaus.wordpress.com/2012/07/02/new-library-examples-and-features/ -- one of the replies by eg1l spelled out the solution -- I'll grant myself the liberty to repost it here, but please remember where it originally came from and link to the original article (exclusively or in addition).

mkdir ~/tmp
cd ~/tmp/
sudo apt-get install libudev-dev libusb-1.0.0-dev libfox-1.6-dev autoconf cmake

git clone git://github.com/signal11/hidapi.git
cd hidapi/
./bootstrap
./configure
cd libusb/
make
sudo make install

cd ../../

git clone git://github.com/edorfaus/TEMPered.git
cd TEMPered/
mkdir build
cd build/
cmake ..
make
cd utils/
sudo ./tempered 
cd ../
sudo make install

sudo ln -s /usr/local/lib/x86_64-linux-gnu/libtempered.so.0 /usr/local/lib/libtempered.so.0
sudo ln -s /usr/local/lib/x86_64-linux-gnu/libtempered-util.so.0 /usr/local/lib/libtempered-util.so.0
sudo ldconfig

sudo tempered
0006:000e:01 0: temperature 21.75 °C, relative humidity 49.1%, dew point 10.6 °C

Create an 80-temper.rules file in /etc/udev/rules.d:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7401", GROUP="users", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7402", GROUP="users", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7403", GROUP="users", MODE="0666"

Then do
sudo usermod -a -G users $USER

And
sudo service udev restart

Unplug and re-plug your device, then open a new terminal and you're set (type group to make sure that users show up).

me@boron:~$ tempered
0006:000f:01 0: temperature 23.34 °C, relative humidity 46.8%, dew point 11.3 °C

20 May 2014

578. More Gnome issues -- semi-rant

I was able to get on with work in spite of transitioning to gnome 3 -- but only thanks to the frippery extensions:
http://verahill.blogspot.com.au/2011/11/debian-testing-64-bit-gnome-3gnome.html 
http://verahill.blogspot.com.au/2013/04/402-very-briefly-what-i-forgot-about.html

And then gnome-screenshot got crippled, but I managed to cope with that by patching it:
http://verahill.blogspot.com.au/2012/06/fixing-gnome-screenshot-341-in-debian.html

I'm using debian testing (jessie) on my laptop and since I normally don't do much on it other than occasionally log into work to check on jobs I have been able to ignore the issues that are so apparent in gnome 3.12, two of which are:

*  gnome-terminal doesn't have a transparent background option since ersion 3.8 -- instead of being able to read what's underneath (e.g. a blog post with a how-to), and thus making good use of the screen real estate, my laptop screen is now feeling very, very small.

[And the developer seems to have the usual gnome attitude issue: https://bugzilla.gnome.org/show_bug.cgi?id=698544 ]

gnome-terminal 3.12
 There's basically nothing that has forced me to stay with gnome-terminal, so switching terminals was a simple matter of installing xfce4-terminal instead, which looks pretty much like gnome-terminal used to. Besides, I use guake more of the time anyway.

xfce4-terminal

 * you can't resize 'native' gnome programs, such as nautilus, that are in full-screen mode. Well, you can -- by holiding super (i.e. windows button) + down arrow. But the icons in the top right corner are no longer, and I find that incredibly annoying.
Nautilus. Nautilus shows when dropbox is synced -- thunar doesn't.

Thunar -- like nautilus of days gone by
 There are two things that I need from nautilus (other than working as a filemanager, of course, and allowing me to open terminals where I want which is something thunar supports 'out of the box') -- the ability to batch resize images, and dropbox. Now, dropbox has nothing to do with nautilus and the dropbox server will run happily in the background whether you're using a file manager or not. It would be nice if thunar would show whether the dropbox folder is synced or not, but it's hardly crucial.

Image resizing is a different matter since we maintain our own little website with personal photos for overseas members of our families. Ergo, it's crucial.

Luckily, this is pretty easy:
sudo apt-get install simple-image-reducer

Go to Edit/Configure custom actions... and set command to simple-image-reducer %F, and scope to apply to images, as shown in the screenshots.





I'm sure there are lots of other small issues in gnome 3.12 that I either keep missing or wilfully ignore in the interest of maintaining a low blood pressure. The whole idea of removing features that are actually useful with no way of re-enabling them smacks of 'we know better than you', and that irks me.

15 May 2014

577. Skype and webcam on debian wheezy: black screen

This is another shameless re-posting of a solution published by others. See e.g. 
http://community.skype.com/t5/Linux/Webcam-is-not-working-on-skype-with-Ubuntu-12-04/td-p/858418
https://bbs.archlinux.org/viewtopic.php?id=95388
http://ubuntuforums.org/showthread.php?t=966882

Why am I doing this? Mostly because this blog doubles as a notebook where I can write down solutions that worked for me so that I don't find myself scouring the internet over and over again for the same solution.

I hope that I'm adding a bit of value by providing step-by-step solutions and snazzy screenshots though.

The issue:
even though the camera is working fine there's only a completely black picture in skype (not underexposed -- just plain black):






The solution:
Use LD_PRELOAD to load the 32 bit V4L library (which you need to have installed -- use apt-file to find out what package). You can either start skype from the command line, or make changes to the launcher, either via main menu  as shown in the screenshot or by editing ~/.local/share/applications/skype.desktop i.e. run skype with 
env LD_PRELOAD="/usr/lib/i386-linux-gnu/libv4l/v4l1compat.so" skype


 At this point starting skype + webcam should be a happy marriage:
(aside from exposure, white balance etc. etc.)

13 May 2014

576. Shortening the bash prompt in debian

This is yet another post in which I'm (almost) simply reposting a solution that someone else has already posted online.

Let's say that my contribution is to put it in context of debian.

Either way, here's the problem that needed solving: the debian prompt by default lists all directories, which sometimes means that the prompt itself breaks across two lines.

Luckily, it's not difficult to chop the prompt down to a more manageable, yet still informative, length. The solution is here (we do like a descriptive URL): http://superuser.com/questions/387673/how-can-i-limit-the-number-of-directories-in-my-prompt

That particular solution also allows you to change the permissible length of the path that will be shown -- change the 50 in the argument to droppath to set the number of chars.

Edit your ~/.bashrc and add the bits in red:
# drops first portion of a path $1 if length is greater than $2 function __droppath { if [[ ${#1} -gt $2 ]]; then p=$1 while [ ${#p} -gt $2 ]; do p="/"$(echo "$p"|cut -d"/" -f3-) done echo "..."$p else echo $1 fi } if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]$(_droppath "\w" 50)\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h: $(__droppath "\w" 50)\$ ' fi

and here's an example using a length of 25 chars (which is a bit short).

Unmodified:
me@niobium: /usr/local/lib/python2.7/site-packages$\

Modified:
me@niobium: .../python2.7/site-packages$

You can always use pwd to figure out what the full path is if necessary:
me@niobium: .../python2.7/site-packages$ pwd
/usr/local/lib/python2.7/site-packages

12 May 2014

575. Gaussview: CConnetctionGFCHK::Parse_GFCHK() Missing or bad data: Alpha Orbital Energies Line Number XXXX

I've been getting a fair number of errors when trying to open .fchk files with gaussview 4.x that I've generated using g09. In particular, I've been getting this:



Thinking that it might have something to do with the version of gaussview being too old, I tried gaussview 5.x, which throws the same error. Gaussview (4.x), by the way, runs fine in wine 1.7.

Turns out it's a poorly written piece of software -- gaussview can't properly parse output generated by gaussian. Great...neither piece of software is cheap. Better yet, gabedit does not have any issue reading the unmodified fchk file.

If you do need to use gview though, the solution is outlined here: http://www.ccl.net/cgi-bin/ccl/message-new?2012+07+18+005

Briefly, edit your fchk file and change the "Number of basis functions" to the same number as is shown for the "Number of independent functions" i.e. change
1 alpha 2 FOpt RB3PW91 Gen 3 Number of atoms I 101 4 Info1-9 I N= 9 5 89 86 0 0 0 100 6 2 18 -602 7 Charge I 7 8 Multiplicity I 1 9 Number of electrons I 530 10 Number of alpha electrons I 265 11 Number of beta electrons I 265 12 Number of basis functions I 2015 13 Number of independent functions I 2005 14 Number of point charges in /Mol/ I 0 15 Number of translation vectors I 0
to
1 alpha 2 FOpt RB3PW91 Gen 3 Number of atoms I 101 4 Info1-9 I N= 9 5 89 86 0 0 0 100 6 2 18 -602 7 Charge I 7 8 Multiplicity I 1 9 Number of electrons I 530 10 Number of alpha electrons I 265 11 Number of beta electrons I 265 12 Number of basis functions I 2005 13 Number of independent functions I 2005 14 Number of point charges in /Mol/ I 0 15 Number of translation vectors I 0
And that's it.

09 May 2014

574. Texmaker and texlive on windows xp

There are two ways of dealing with latex on windows -- either using native packages or via cygwin. Here's the  native approach, which I tested in a virtual machine with Windows XP SP2

 
1. Install texlive

Go to http://www.tug.org/texlive/acquire-netinstall.html and download http://mirror.ctan.org/systems/texlive/tlnet/install-tl.exe

Run the file. You'll now be taken through the installation of texlive. Note that the full installation is ca 3.7 Gb and it will take a few hours to download and install. On the other hand, space is cheap and most people (in academia) don't pay for bandwidth, so it's not a bad idea to do the full install.

Anyway, here are a few screenshots of the installation process:



It's a good idea to change the mirror to speed up the download



Uncheck TexWorks since we'll be installing TexMaker


This step can take many hours


Finally done.


2. Install texmaker

Go to http://www.xm1math.net/texmaker/download.html and download http://www.xm1math.net/texmaker/texmakerwin32_install.exe

The same file will work on XP, Vista and 8 (and presumably 7, which is more or less a patched version of Vista) and it will work on both 32 and 64 bit systems.

Install texmaker.


3. Configure  texmaker
Start texmaker

Go to Options/Configure Texmaker.

Under Commands you can select to use an external pdf viewer. Note that you will need to make sure that the path is correct -- in my case it was pointing to adobe reader 11, whereas I had adobe reader 9 installed. Easy enough to change, but you need to do it manually. The embedded/internal pdf viewer works ok, but distorts the text and figures somewhat (everything got a bit squashed)
Choose internal or external pdf viewer. Make sure the path is correct
Under Quick Build you can tick Latex+Bib(la)tex+Latex(x2)+dvips+ps2pdf+View pdf. NOTE: if you do this you won't be able to compile any file which hasn't got a \cite command and a mathing .bib file.

Alternatively, pick latex + dvips + ps2pdf + View pdf.

Quick Build -- pick the one with bibtex in it
Under Editor you can disable code completion (which can get annoying at times):

You can now load a tex file and hit F1 to compile it:


Quick test example

0. Create a folder called e.g. testtex
 
1. Download UCSD.eps from here: http://vectorlogotypes.net/logo/68332_UCSD.htm

Put it in the testtex folder.


2. Create the following anothertest.bib file in either texmaker or notepad:
@Article{2014:example,
  AUTHOR = {Placeholder, A},
  TITLE = {Comprehensive title},
  YEAR = 2014,
  JOURNAL = {J. Comp. Chem.},
  VOLUME ={45},
  PAGES = {100-101}
}
Put it in the testtex folder.

3. Create a new tex file in texmaker:


Make sure to tick graphicx

Basic tex file
Save to your testtex folder.

4. Edit your tex file as shown below::
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}

\usepackage{url}
\title{This is a test}

\begin{document}

\section{The test}
This is a simple test which consists of inserting a figure and adding a reference via bibtex. You can download the logo from \url{http://vectorlogotypes.net/logo/68332_UCSD.htm}. Put the UCSD.eps file in the same directory as your .tex file.
\begin{figure}
 \includegraphics{UCSD.eps}
 \caption{UC San Diego logo.}
 \label{fig:test}
\end{figure}

Here's a citation.\cite{2014:example}

\bibliography{anothertest}
\bibliographystyle{ChemEurJ}
\end{document}
5. Compile.
If you set up your F1 as shown above (i.e. with bibtex support), then all you need to do is hit F1. Otherwise, if you used the alternative setup, do F2 (latex), F11 (bibtex), F2 (latex), F11 (bibtex), F1 (compile and view).