Thursday, October 1, 2009

Latex Tip: Author Affiliations

I've been writing in LaTeX a lot recently, and found a nice little package to use when composing a document with authors with different affiliations.  Often, author order is affiliation independent, so the authblk package makes all this possible.  Here's the sample code:


\documentclass[10pt]{article}


\usepackage{authblk}
\renewcommand\Affilfont{\itshape\small}


\begin{document}


\title{Author Affiliations in \LaTeX}
\author[,1]{Arthur A. Filliation\footnote{aaf@mail.com}}
\author[,2]{Arthur A. Filliation Jr.\footnote{aaf2@mail.com}}
\author[1]{Con T. Ributor}
\affil[1]{Department of Latex Studies.}
\affil[2]{Typesetters of America}
\date{\today}
\maketitle


\end{document}


A few notes.  First, renewing the command \Affilfont allows you to change the look of the affiliation list.   However, the small italic font seems pretty standard, so this is what I've always used.  Second, the option following the \author command adds a superscript corresponding to one of the affiliations stated by the \affil command. When using this command while also adding a footnote for contact information, the two superscripts will need to be separated by a comma.  You'll have to manually put this comma in after the \author command.  When all is said and done, you should get this:




Saturday, June 6, 2009

Quick Remote Editing With Vim

I am sure that anyone who has created their own website has had to make simple edits. There are many ways that one may connect, edit, and then publish the changes and all of these ways accomplish the task at hand. I wish to show a quick and easy way to edit remote files using Vim.

user@local~$ vim ftp://hostip/file.py

OK thats it. Told you it was quick. Save and quit (:wq) and your file is updated and published.

There is a huge learning curve to Vim but I think that with time, you will find yourself being more efficient.

Wednesday, May 6, 2009

Search Youtube in Totem

I never knew this, but you can search youtube videos through Totem. Watch the video below

Friday, March 20, 2009

Creating 3D Spheres in Adobe Illustrator CS3

As I mentioned in previous posts, I do some molecular dynamics work. It's helpful sometimes to have cartoon-ish pictures to aid in atomic visualization, especially when describing domains with different types of atoms. I'm also a big fan of really pretty graphics, even at the expense of time. I got a copy of Adobe Illustrator CS3 after using CS for way too long, and decided to play around. After a Google search I found out most of the information I needed, but was unfamiliar with the use of some of the tools. After compiling information from a few different sites, I finally got the hang of it. Still, what's the point in learning if you don't share what you know?

Once you're in Illustrator you're going to want to start with a simple circle. I usually show the grid and set snap to grid via the View menu. Make the path invisible and fill the circle with a solid color of your choice. Next, you are going to use the scissors tool (often hidden under the eraser or knife tool) to cut the circle in half. Do this by actively selecting the circle (so the paths are shown, you can do it with the white pointer known as the direct selection tool). Next, with the scissors tool, click the anchor point at the bottom of the circle, and then again at the top of the circle. If this has been done correctly, the middle point of the circle will suddenly shift right as shown in the pictures. Drag the right half of the circle away and delete the left half. Next, select the right half of the circle and go to Effect -> 3D -> Revolve. Leave the settings as the default, and select the preview box. You should now see your 3D sphere. Feel free to play with the lighting and other options, but I've found the default settings look best.

Thursday, March 12, 2009

Installing gnuplot on Mac OS X 10.5 (Leopard)

Not to many people's surprise anymore, I'm both an engineer and a Mac user. While this would have been a serious anomaly a couple years ago, it seems more and more common these days, especially when working with other Unix/Linux machines. That aside, I had long been plotting all my data using the various functions in Matlab, and for the most part, I was very happy with the results (see here for reference). What I found, however, is that 3D scatter plots came out looking pretty terrible, and my start in molecular dynamics simulations required the scatter plots somewhat frequently.

So, there I was, looking lustfully at the gnuplot demos, so rich in their 3D visualization options. However, after downloading, extracting, and messing around in the terminal I found latest build (4.2.4) was having some issues with the makefile, even after configuration. I searched on the web for a while for some help which was fruitless until I stumbled upon this little nugget, which was a great relief, as I tend to be sort of lazy when sifting through readme's. To be honest, that entry alone has all the information you really need, but it assumes some basic awareness of a few things I hadn't heard about before, so I thought I'd post this information in a more outright manner.
  1. MacPorts: Probably one of the coolest things ever, simple as hell, and quite powerful. MacPorts allows you to install a number of software packages by simply typing "install packagename" in the Terminal. Installation of MacPorts is a breeze once you download their disk image (.dmg) and run their installer (.mpkg), which you can get here.
  2. Once MacPorts has been installed, you'll need to start a new Terminal session. At that point, it's as easy as typing "sudo port install gnuplot" in the Terminal. I'll warn you, this installation can take a while (~30 minutes) as you download and install all the smaller software packages required.
And that's about it. Just start the terminal up and type "gnuplot". If there are any questions, leave a comment. I've only done this on 10.5, but MacPorts claims to support the latest OS, and the last release (10.4 for now). I have no reason to doubt anything they say considering how simple this all was. They should start some funny rumors since their credibility is so high right now.

UPDATE: Thanks to some feedback, I failed to note that you should install X11 and XCode before attempting to install MacPorts. X11 is available on your OS X install disc, and XCode is available (at no cost) on the Apple Developer webpage.

Wednesday, March 11, 2009

March Madness on your Conky

March Madness is here and and what better way to keep track of the action than with a scoreboard tracker at the bottom of your screen. Check out the image below:

This is accomplished by combining a python script with the conky variable scroll. The python script will get the data, parse it and put it into a acceptable format for conky to handle the display. I've talked about conky earlier and using displaying the last instant message.

Copy the following code and save it as bottomscore.py


#!/usr/bin/python
import urllib
# Open html page
fweb = urllib.urlopen("http://scores.espn.go.com/ncb/bottomline/scores")

gamestr=''
score=''
# Manipulate str for unneccessary chars
raw=str(fweb.readline())
raw=raw.replace('%20',' ');
raw=raw.replace('^','');
raw=raw.replace('&','\n')

# Open data storage
f=open('bottom.dat', 'w')
f.write(raw)
f.close()
f=open('bottom.dat', 'r')

# Parse each line, get game, create str, append str
for line in f:
if line.find('_left')>1:
gamestr=line[line.find('=')+1:-1]
score= score + gamestr + ' | '

f.close()
print score


My conky script is as follows. Save this
#avoid flicker
double_buffer yes

#own window to run simultanious 2 or more conkys
own_window yes
own_window_transparent no
own_window_type normal
own_window_hints undecorate,sticky,skip_taskbar,skip_pager, above

#borders
draw_borders no
border_margin 0

#shades
draw_shades no

#position
gap_x 0
gap_y 0
alignment bottom_middle

#behaviour
update_interval 1

#colour
default_color 8f8f8f
#default_shade_color 000000
own_window_colour 262626

text_buffer_size 1400

#font
use_xft yes
xftfont bauhaus:pixelsize=10

#to prevent window from moving
use_spacer none
minimum_size 1400

TEXT
${color e0e0e0} ${scroll 2847 ${execpi 60 python ~/scripts/bottomscore.py}}

Remember to edit your .conkyrc to run the right path to bottomscore.py. You may need to edit certain parameters for your screen resolution but this should give you a good start. Any questions, post a comment.
Pro Tip:To run multiple conky screens:"conky -c .conkyrc2"

Monday, March 2, 2009

How to Burn Compressed Video Files to DVD in Ubuntu

With some help from Realtimeedit and MEncoder, I developed a script file to convert common compressed video files into an .iso file which can be burned onto a DVD for set top playback on your TV.

Before you run the script, you'll need to install the following packages:

MEncoder: sudo apt-get install mencoder
DVD Author: sudo apt-get install dvdauthor

Download the script file here.

When you run the script it will prompt you for the directory, name, and extension of the video file. It will then prompt you for the aspect ratio of video file and run MEncoder to decompress the file to an mpeg format. It will then run DVD Author to write to DVD format and create an .iso file.

Use any DVD burning software to burn the .iso image to a DVD.

Hope this works for you, any comments are always appreciated.

Friday, January 30, 2009

How To: MPD/MPC with Ubuntu

For a few months now I wanted to try mpd mainly out of curiosity. Music Player Daemon (mpd) is a music server and mpc will be the client used to interact with the server. This how to will look at a localhost server of mpd.

Prereqs: Enable universal repositores in /etc/apt/sources.list

Installing & Configuring Software:
In terminal:
sudo apt-get install mpd mpc paprefs
Next we need to set up Pulse Audio.
Go to System->Preferences->Pulse Audio Preferences
Check "enable network access to local sound device" & "Don't require authentication"
Set up mpd.conf (use your favorite text editor)
sudo gedit /etc/mpd.conf
Add the following to the config file:
audio_output {
type "pulse"
name "Local MPD Output"
}
In the mpd.conf file, look for "music_directory" and change the corresponding path to your music directory.

Next, we shall build the database. In terminal, type:
sudo mpd --create-db
Finally, restart mpd by:
sudo /etc/init.d/mpd restart
Using mpc: mpd/mpc is higly scriptable so I recommend create some bash files for yourself. You will find the manual to mpc here: http://linux.die.net/man/1/mpc

Example: Add Radiohead to current playlist
mpc search artist Radiohead | mpc add
mpc play
Good luck

Further Reading:
http://mpd.wikia.com/wiki/What_MPD_Is_and_Is_Not
http://mpd.wikia.com/wiki/Hacks

Friday, January 16, 2009

MATLAB: Set working path at startup

Many times when MATLAB is started there is a certain program that you want to work on. In order to work on this program, the current directory or path of that program must be changed or set.  This little script here will prompt the user for the module to work on and then add that directory to the path listing. When MATLAB is terminated, that path will not be saved.
% startup.m

% Set Production Directory
prod='~/MATLAB/Production/';

% Prompt user for module name
module=input('What module do you want to work on? ','s');

% If module is set, add to top of path. Otherwise don't add
if ~isempty(module)
path([prod,module],path);
end
Place the startup.m in your MATLAB work directory.

Thursday, January 15, 2009

Plotting in MATLAB / Making Plots Look Pretty

Alright, well, here's the scoop. Ditto wanted a v2.0 remake of a post that we started late last year. And, well, I give him whatever he wants. So, without further ado, here's Pretty Plots in Matlab, v2.0.

Using MATLAB to crank through some calculations, but having trouble making the plots pretty? Here's an example that should make a nice looking plot that's ready to be inserted into a report.

X=[1 2 3 4 5 6 7 8 9 10];
Y=X.^2;

xmin=0;
xmax=11;
ymin=0;
ymax=110;

figure
set(gca,'fontsize',14)
set(gcf, 'PaperSize', [8. 6.],'PaperPositionMode', 'auto');
plot(X,Y,'k^','markersize',10,'markerfacecolor','r')
legend('mylegend','location','northeast');
xlabel('my $x$ label','Interpreter','latex','fontsize',16);
ylabel('my $y$ label','Interpreter','latex','fontsize',16)
AXIS([xmin xmax ymin ymax])
print('-r600','-dpdf',['filename','.pdf'])

Copy, paste, and run, and you should get this (in the directory your current directory):



Alright, a quick rundown.

1. The 'figure' command is letting MATLAB know that we're making a picture with all the following attributes.
2. The 'set gca' command is setting the axes, which have the default handle 'gca', to have a font size of 14 here. This will control the size of the numbering on the axes, as well as the size of the font in the legend.
3. The 'set gcf' command is setting the paper size to 8" by 6", a size I find works well with the default figure output of MATLAB. This will prevent you from having to crop the plot later in a third-party photo editor.
4. The 'plot' command lists the X and Y arrays youd like to plot, 'k^' plots black upward facing triangles in a 'marker size' of 10pt, and filled red.
The 'legend' command puts in your legend, one entry per pair of vectors being plotted, in the northwest position.
5. The 'xlabel' and 'ylabel' commands are pretty straightforward, but the interpretter command displays the labels in the default LaTeX font instead of the MATLAB font. You can use the '$$' pairing to put in maths (the x and y).
6. The 'axis' command sets the range for x and y, just comment this out if you like what MATLAB does.
7. The 'print' command will save your figure as .pdf with the filename you specify in the current directory (where your .m file is). Here, you can always specficy a path if you'd like to save figures in a different folder.

Still to come, using str2num and num2str to automatically number plots that are part of a for loop, or to name output graphs based on input data.

Friday, January 9, 2009

Woah, October 10, 2010

Today I had a mind blowing realisation that any geek would appreciate. Not sure if its well known but it soon will be. The number 42, which in case you didn't know, is the answer to everything, the universe and life, referring to The Hitchhiker's Guide to the Galaxy (see here).

Next year, October 10, 2010 will be here and it can be written as 10/10/10. Or removing the slashes, 101010 which converting from binary to decimal form is 42. Woah. Yeah, woah. Will the answer to life appear on October 10, 2010. I dont know, but someone will make mad money making t-shirts.

I think the meaning will come from the web comic xkcd.com. In case you did not know, the ordinal values of xkcd add up to 42.

Get your tinfoil hat ready.

Sarah Palin Pwns the Media Elite

Booyah!

enjoy...

-migs

Wednesday, January 7, 2009

The Music of Four Loves Four - 2008

As the 2008 comes to a close, here are the top ten artists that the author's of Four Loves Four listened to.

Ditto's Top Ten
  1. Radiohead
  2. Coldplay
  3. Van Morrison
  4. Pearl Jam
  5. Death Cab for Cutie
  6. Kanye West
  7. Mat Kearney
  8. Counting Crows
  9. The Decemberists
  10. Incubus
Doodah's Top Ten
  1. Tokyo Police Club
  2. Say Anything
  3. Owen
  4. Sufjan Stevens
  5. Someone Still Loves You Boris Yeltsin
  6. Vampire Weekend
  7. Royksopp
  8. The Appleseed Cast
  9. Pompeii
  10. Nada Surf
Mig's Top Ten
  1. Radiohead
  2. Death Cab for Cutie
  3. Christopher O'Riley
  4. Dave Matthew Band 
  5. Broken Social Scene
  6. Snow Patrol
  7. Jack Johnson
  8. Feist
  9. Van Morrison
  10. The Decemberists
A look at the musical tastes of the people who drive this site.
Thanks to all who subscribe.

Monday, January 5, 2009

I'm Boycotting the Progressive Insurance Commercial Girl...

...and so should you. Flo is bothering me just like Joe Buck did in 2004. We all know what happened there. (To refresh your memory)

Just so I know what I'm working against, I did a little detective work. Her name is Stephanie Courtney and here is a list of films and works I will not be watching until Progressive takes my demands suriously and ends these commercials.

Join my Cause.

-migs out

btw, I will be entertaining myself at the Nova/Seton Hall game tomorrow night at the ROCK and then watching the premier of Scrubs on ABC.