Wednesday, May 9, 2012

Flight tracking

As I prepare to head to Bielefeld for summer research, a young woman's fancy turns lightly to the thought of getting the lowest airfare possible. How long should I wait? I've heard that at 21 days out, prices start dropping as airlines try to fill seats. I've been looking for my ticket for a while, and so far I've seen no evidence of a significant change either way around 21 days. I more rigorously searched fares manually one day and noticed that a quite significant drop may actually occur around day 14. But that seems like it's cutting it awfully close...How can I be sure? Was that one day just a fluke?

Step 1: Search Expedia automatically for the lowest fare available for my point-of-origin/destination starting with 1 day out (tomorrow) up until my actual day of departure (the 28th). Wow, that's only 19 days. I'm cutting it close regardless... (Don't worry, while my evidence on the 14-day drop is equivocal, I've seen no evidence whatsoever that the last-minute price rise occurs before 7 days out, and most likely occurs about 3 or 4 days out.)

#!/usr/bin/python                                                                                          

import os

departuremonth="05"

i=9
while (i<=28) :
    departureday=str(i)

    cmd = 'curl http://www.expedia.com/Flights-Search?trip=roundtrip\&leg1=from:Indianapolis,%20IN,%20Unite\
d%20States%20%28IND-Indianapolis%20Intl.%29,to:Frankfurt,%20Germany%20%28FRA-All%20Airports%29,departure:'+\
departuremonth+'%2F'+departureday+'%2F2012TANYT\&leg2=from:Frankfurt,%20Germany%20%28FRA-All%20Airports%29,\
to:Indianapolis,%20IN,%20United%20States%20%28IND-Indianapolis%20Intl.%29,departure:08%2F03%2F2012TANYT\&pa\
ssengers=children:0,adults:1,seniors:0,infantinlap:Y\&options=cabinclass:coach,nopenalty:N,sortby:price\&mo\
de=search > relly3'

    os.system(cmd)

    resultsfile = file("relly3",'r')
    lines = resultsfile.readlines()
    for line in lines:
        if line.find("formattedLowestPrice")!=-1:
            removeKey="formattedLowestPrice\">"
            removefrom=line.find(removeKey)+len(removeKey)
            line=line[removefrom:]
            removeto=line.find("<")
            line=line[:removeto]
            print departuremonth+"-"+departureday+"-12: " + line

    i+=1

Thursday, November 17, 2011

bibtool

I'm extremely disorganized, and I suffer from a lot of information duplication. (I'm working on it.)

In the meantime, however, I need to get my LaTex citations handled! So I'm using bibtool on an .aux file and a set of bib files to produce a bib file just for that paper, with only citations that are required by the paper. Once I get organized, I won't need to do this. Till then:

/home/pscherme/bin/bibtool -s -d -x all_papers.aux review.bib newbib2.bib system2.bib new.bib > all_papers.bib

Wednesday, October 26, 2011

Insert something from the kill ring after the cursor

Another accidental discovery: Ctrl-u, typed before the typical Ctrl-y, means the thing that is inserted will be after the cursor instead of the default before.

Monday, August 22, 2011

Java pun

It is when I am coding that I am most likely to use the terms "argh" and "rargh". Today while fretting over some command-line argument handling, I find I wrote the following in my notes:

"Arg, what is the usual way of doing this???"

It took me a minute to figure out why I appeared to be addressing the argument...

Monday, August 1, 2011

My Least Favorite Thing About stackoverflow

...when people comment a question with, "I don't know LaTex, but you shouldn't do what you want to do because of (insert totally subjective opinion, such as 'tables look better without vertical lines anyway' here)".


It just makes me want to mod your comment down "irrelevant"! And it happens all the time with the LaTex questions!

And also, for the 2000th time: yes, I realize tex.stackexchange exists. Yes, I realize that the person who asked the question could have answered it themselves with 2 minutes on google and a toy example to play with. But I learn a lot about things I never even thought about when LaTex novices ask easily-googled questions on stackoverflow, so stop with the silly comments! If you can't answer the question, then don't answer it, okay!

Thursday, July 21, 2011

Emacs

The main reason I love emacs is because sometimes, I will inadvertantly hit a strange key combination and -- something unexpected will happen! Today I learned through this method that M-c will capitalize a word. That's a feature I don't need often, but whenever I do -- emacs will be there!

Update: I learned this while preparing to work on creating slides from a paper. A few minutes later, as I was collecting all statements of each main idea from my tex file and assimilating them into one single, complete statement for each main idea, I was about to manually capitalize a word but I remembered in time: Meta-c!

Monday, July 18, 2011

Bayes vs. Markov

I was perhaps unjustifiably surprised as I was going through the Naive Bayes classifier model to find that it looks very similar to something I'm already quite familiar with. Basically, if you start from Bayes' Theorem and go one direction (conditional probability), then make independence assumptions, you end up with the model for the NB classifier. If you go a different direction (chain rule) and then make independency assumptions, you end up with a Markov model. I'm guessing a lot of other models are quite similar too...