Andrew Que Sites list Photos
Projects Contact
Main

October 26, 2007

Hard drive prices

    Back in April I wrote a script to keep an eye on hard drive prices.  It's acquired a bunch of data since it started running, and being the number happy guy I am, I wanted to have a closer look.  I exported all 15,000 records from the database and imported them into an Open Office spreadsheet.  A bit of organization and I turned out these:
500 gig
    Right now, 500 gig drives are the best value per gig of space.  A couple of online stores seemed to be in a price war in early September, but it appears that is over and prices have come back up.  Prices got down to around $0.18.gig.  It may be that refurbished drives were being included in the new drive listings.  I've since seen separate categories for referb drives, but I'm not sure when that happened.
750 gig
    750 gig drives are coming in behind 500s lately.  Around the first of October they all had a noticeable drop in price and are now sitting around $0.22/gig.  That's not bad, considering I payed about $0.20/gig for my 500 gig back in May when 750s were at $0.33/gig.  I think in a few more months, we'll see 750 gig drives dropping below 500s in price.

    The terabyte drives.  Pricewatcher didn't track them until late April, so I started the graph in May.  Listing became reliable in June and the price has very slowly been coming down.  But with the graph, you can clearly see the scatter.  Prices can change wildly.  However, the fact you can now buy a full terabyte of storage for under $275 is impressive.  Today is a new low for this drive at $0.27/gig, and the price will keep dropping I'm sure.
    I couldn't resist using my recently acquired linear regression skills for this project, and it seems a good place to use it as well.  From the regression plots we can get an idea for how much prices are changing.  The graphs can be a little misleading, since they are scaled based on min/max price during the time span.  500 gigs have had the most dramatic price drop--70% in 6 months at an average rate of $0.14/day.  750 gigs are dropping at an average rate of $0.47/day, or 60% in 6 months.  1000 gigs are dropping an average $1.34/day, which seems like a lot, but turns out to be only 41% in 5 months.  Well, enough fun with numbers!...

October 25, 2007

Response for Nathan

Crystal

Crystal

    A couple weeks back, Nathan posted a comment here.  I had begun to write a response, but didn't have time to finish it up.  So I'm going to do that here.  A little late I know, but Physics keeps me busy!

Nathan -

    That is true, the New Testament is an improvement over the old.  As my roommate put it, "The New Testament is after God got on meds."  Apparently Thomas Jefferson wasn't a big fan of the mass-murdering God either and published an edited version of the Bible known as "The Life and Morals of Jesus of Nazareth" where he basicly threw out the Old Testament as well as the supernatural parts like the resurrection.  He isn't the only one who has attempted to modernize the Bible.
    The Bible proclaims to be the word of God and I'd venture to say that most Christians who believe in the divinity of Christ also believe the rest of the Bible to be true, even if not regarded as not as important.  Fundamentalists emphasize that *everything* in the Bible is true and must be taken literally.  More liberal Christians will tell you the Bible is inspired by the word of God but written by man.  So fundamentalists literally believe Noah put to of every animal on a boat and Lot's wife literally turned into a pillar of salt for turning to look at the city of Sodom.  Liberal Christians tend to pick and chose.  What many atheist writers (such as Richard Dawkins) point out is the picking and choosing pretty much nullifies the Bible as a moral guide.  If people simply select what they feel like believing, clearly that decision comes from outside the moral guidelines from the Bible.  That begs the question: why then bother to even use the Bible?  If you're going to selectively pick what you're going to follow, you could just as easily do this with any book you want.
    To come back to your point, Jesus never did away with the laws in the Old Testament.  "For verily I say unto you, Till heaven and earth pass, one jot or one tittle shall in no wise pass from the law, till all be fulfilled. Whosoever therefore shall break one of these least commandments, and shall teach men so, he shall be called the least in the kingdom of heaven: but whosoever shall do and teach them, the same shall be called great in the kingdom of heaven." (Matthew 5:18-19)  There are a few other places in the Bible were the Old Testament is enforced, and also a few places where it isn't.  (See the list)
    Again, if you follow this stuff, you just have to pick and chose--or let someone else pick.  My point, the Bible is the Bible, start to finish.  If God was a ruthless psycho, even if just in the beginning, then He's still a ruthless psycho.  I won't overlook someone committing genocide and proscribing countless sadistic acts just because they've since changed their ways--not even a God.

1 comment has been made.

From Nathan

Chicago

October 27, 2007 at 2:48 AM

Cool. With all the "picking and choosing" and personal stances out there to take, I find that link quite illuminating. Makes me wonder why people bother. I have to wonder, if there were a God, and we acknowledge the the Bible was in fact cobbled and butchered together over time, can I be so sure what to think about God? I just tend to blame Christians, rather than Christianity for all the crazy shit that's gone on for centuries. But, I'm also not that informed. I have read about the progression from one religion to the next from before Rome thru Christianity though, and totally see where so much of Christian mythology comes from, and am quite far from believing it. Not just changed from some 'divine word' but cut and pasted from isis and dionysus, etc. Makes you wonder why it has such a hold on us. I suppose getting the support of a Roman Emperor and then becoming the only source of power in the Dark Ages in Europe for hundreds of years sets a trend. Thanks for the reply. Its helpful for me. Hardly changes my mind about anything obviously, but arms me with good information.

October 24, 2007

PThread in a C class

    Had some time to do some real programming this afternoon which made me happy.  School is interesting and all, but I'm a fan of the applied life.  Lately I've been spending a good deal of time working with the Standard Template Library and C templates.  I also wrote a small PThreads class, since the interface for these are plain C.  I had to come up with a way call the thread from inside a class.  To do this, I made a static function inside the class that the tread will call.  The parameters to the thread are the pointer to the thread object to be executed.  So we can cast the pointer and call this thread's update function.  However, the thread is created before the inherited object is finished initialization, which means the thread can begin executing before the object is fully created.  This leads to bad things and to get around this problem, I force the thread to sleep a bit before it execution.
    The PThread class is abstract, meaning it must be inherited in order to function.  The child class has to define an update function, which is the body of the thread.  The class keeps a list of all the threads, which is useful for starting and stopping all threads.  The list, naturally, is from the Standard Template Library :)

Here is the code. 
 
/***************************************************************************/
/* Name : PThread.hpp                                                      */
/* Uses : A class for pthreads                                             */
/* Date : 10/12/2007                                                       */
/* Author : Andrew Que (http://www.DrQue.net/)                             */
/* Revisions :                                                             */
/*  1.0 - 10/12/2007 - QUE - Creation                                      */
/*                                                                         */
/*                           (C) Copyright 2007                            */
/*                                   ≡|>                                   */
/***************************************************************************/
#ifndef PTHREAD_HPP
#define PTHREAD_HPP

#include <pthread.h>
#include <semaphore.h>
#include <list>
#include <unistd.h>


#include <iostream>

using namespace std;

//---------------------------------------------------------------------------
// Class basic class for POSIX threads
//---------------------------------------------------------------------------
class PThread
{
  private:
   void* Parameters;
   pthread_t Thread;
   pthread_attr_t ThreadAttributes;
   static sem_t* PThreadLock;
   sem_t ThreadInUse;
   bool _IsTimeToStart;
   bool _IsTimeToShutdown;
   static bool _IsFullShutdown;

   static list< PThread* >* ThreadList;

   //----------------------------------------------------------------
   // Update function
   // The thread always calls this function, which, in trun, calls
   // the thread's actual update function
   //----------------------------------------------------------------
   static void* InternalThreadUpdate( void* ThreadPointer )
   {
     // Cast the class pointer 
     PThread* Thread = (PThread*)ThreadPointer;

     // Wait for thread to start
     // NOTE: Wait at least once, since it is posible this function
     // could be called before the thread class has been completly 
     // constructed.
     do
     {
       usleep( 100000 );
     } while ( ! Thread->IsTimeToStart() );

     // Call and return data form the thread
     // NOTE: The parameters are stored in the class
     return Thread->UpdateThread( Thread->Parameters );
   }

  protected:
   //----------------------------------------------------------------
   // Constructor
   //----------------------------------------------------------------
   PThread( void* Arguments )
     : Parameters( Arguments )
   {
     // If the thread list hasn't yet been initilized
     if ( ! ThreadList )
     {
       ThreadList = new list< PThread* >;
       PThreadLock = new sem_t;
       sem_init( PThreadLock , 0 , 1 );
     }

     // Lock the thread list
     sem_wait( PThreadLock );

     // Initilize locals
     _IsTimeToStart    = false;
     _IsTimeToShutdown = false;
     _IsFullShutdown   = false;

     // Initilize semaphore
     sem_init( &ThreadInUse , 0 , 1 );

     // Lock this thread
     sem_wait( &ThreadInUse );

     // Create thread attributes
     pthread_attr_init( &ThreadAttributes );

     // Set thread as joinable
     pthread_attr_setdetachstate( 
       &ThreadAttributes , PTHREAD_CREATE_JOINABLE );

     // Create thread
     pthread_create( 
        &Thread  , 
        &ThreadAttributes ,
        PThread::InternalThreadUpdate , 
        (void *)this );

     // Detach thread
     pthread_detach( Thread );

     // Add thread to list
     ThreadList->push_back( this );

     // Unlock thread
     sem_post( &ThreadInUse );

     // Unlock thread list
     sem_post( PThreadLock );
   }
  public:
   //----------------------------------------------------------------
   // Signal thread to shutdown
   // NOTE: It is up to the thread to follow this request
   //----------------------------------------------------------------
   void ShutdownThread()
   {
     //_IsTimeToStart = true; // <- Just in case
     _IsTimeToShutdown = true;
   }

   //----------------------------------------------------------------
   // True if it is time to shutdown
   //----------------------------------------------------------------
   bool IsTimeToShutdown() const
   {
     return _IsTimeToShutdown;
   }

   //----------------------------------------------------------------
   // True if it's time to start the thread
   //----------------------------------------------------------------
   bool IsTimeToStart() const
   {
     return _IsTimeToStart;
   }

   //----------------------------------------------------------------
   // Signal thread to start
   //----------------------------------------------------------------
   void SetIsTimeToStart()
   {
     _IsTimeToStart = true;
   }

   //----------------------------------------------------------------
   // Destructor
   //----------------------------------------------------------------
   virtual ~PThread()
   {
     // Stop thread
     ShutdownThread();

     //pthread_join( Thread , NULL );

     pthread_attr_destroy( &ThreadAttributes );

     // Lock this thread
     // (we're about to destory it)
     sem_wait( &ThreadInUse );

     // Lock the list
     sem_wait( PThreadLock );

     // Remove this thread from the list
     ThreadList->remove( this );

     // Unlock list
     sem_post( PThreadLock );

     // Trash semaphore
     sem_destroy( &ThreadInUse );
   }

   //----------------------------------------------------------------
   // Signal all threads to shutdown
   //----------------------------------------------------------------
   static void SignalAllThreadShutdown()
   {
     // Signal all thread to stop
     list< PThread* >::iterator ThreadListIterator;
     for ( ThreadListIterator  = ThreadList->begin()
           ThreadListIterator != ThreadList->end()
           ThreadListIterator  ) 
     {
       (*ThreadListIterator)->ShutdownThread();
     }
   }

   //----------------------------------------------------------------
   // Signal all threads to shutdown and wait for them to finish
   //----------------------------------------------------------------
   static void ShutdownAllThreads()
   {
     SignalAllThreadShutdown();

     // Signal all thread to stop
     list< PThread* >::iterator ThreadListIterator;

     // Wait for all threads to stop
     for ( ThreadListIterator  = ThreadList->begin()
           ThreadListIterator != ThreadList->end()
           ThreadListIterator  ) 
     {
       pthread_join( (*ThreadListIterator)->Thread , NULL );
     }

     _IsFullShutdown = true;
   }

   //----------------------------------------------------------------
   // Returns true if all threads are being shutdown
   //----------------------------------------------------------------
   static bool IsFullShutdown()
   {
     return _IsFullShutdown;
   }

   //----------------------------------------------------------------
   // Thread function (pure virtual)
   //----------------------------------------------------------------
   virtual void* UpdateThread( void* ) = 0;
};

#endif // PTHREAD_HPP

October 23, 2007

180 days of runtime

    This Indigo-Dragon has reach 180 days of continuous runtime.  It's been a few years since I had a server do this.  The Indigo-Dragon is running on a Debian base and serves all the web pages as well has provides an SSH gateway, FTP, e-mail and Rsync.  There has been recent talk of installing Subversion on it was well for my programming class.

October 21, 2007

Linear regression

    Last weekend while writing up my lab report of my physics class, I played with something kind of cool.  The lab was fairly simple: we were to measure circles and based on the measurements, calculate a value for Pi.  Part of the lab involved making a plot of the diameter vs conformance of the circles we measured.  I think I tried this about 5 times before I decided my graphing skills were probably on par with those of an 8-year-old.  The slope of this line should have been Pi--and Pi isn't around 2.
    I knew my data was more accurate then my graph, so it was time to break from procedure and do things the right way.  The purpose of drawing the graph was the idea of using approximate linear regression.  I'm a math major with a PC--why would I need to break out graph paper to get an approximation?  I can get the precise linear regression slope.
    My guess was OpenOffice had some kind of linear regression fetcher built in, and it didn't take more then a few moments of searching google to find out how to use it.  Soon I had graphs and an approximation of Pi that was 99.46% accurate.  I knew I'd have to explain how I did this in the lab write up, so I looked up for formula for linear regression.  After reproducing the same numbers as OpenOffice, I felt pretty good about it.  Maybe I'll get marked down for not following the directions, but to me, learning how to make my computer tackle a particle problem was more important then an academic exercise.  Have a look at the lab write up.
    Pictured is Allison.

2 comments have been made.

From Nathan

Chicago

October 22, 2007 at 1:36 AM

man, that writeup is insane. I feel like a neanderthal when I look at that stuff. I found myself more interested in what made the manual graphing hard. I guess we all have our interests.

From echo

October 23, 2007 at 11:38 AM

stalky stalky. you shouldn't get marked down for lack of graphing skill as long as you did you calculations and explained the process(which you did, I saw), unless of course your teacher's a tool in which case your out of luck.

October 20, 2007

"Letter to a Christian Nation" by Sam Harris

    Started and completed "Letter to a Christian Nation" by Sam Harris.  It's a worthwhile read but didn't grab me as much as some of the other books on this topic, such as Christopher Hitchens' "God is not Great" or Richard Dawkins' "God Delusion".  Perhaps this is because I've read/watched so much content of Harris already, so most of what is covered in the book I've already heard.
    The book is as the title would lead one to believe: a letter to a Christan.  Not being a Christan, I found myself thinking "not me while reading lines like "you believe" and "your religion".
    What concerns me with the book are the hints of the hype.  Harris regularly attributes the suicide attacks of 9/11 to the attacker's fundamentalist beliefs--particularly martyrdom.  He points out that the men responsible for the attack were strong believers in their faith and indirectly suggests that if they didn't have these strong religious convictions, they would not have voluntarily blown themselves up.  I initially gave this idea some thought, but I've had to deisms it.  I think hatred drove these men.  Eric Harris and Dylan Klebold were not religious fundamentalists believing they would become martyrs.  Yet they willingly went on a killing spree at Columbine High School with the full intention of ending their lives when it was over.  It was a suicide mission.  I think both these cases, both of which were premeditated murder and suicide, were driven by hate, not religion.  In the case of the Columbine kids, their hate came from years of social conditioning at their schools. As for the 9/11 hijackers--there's a huge list of reasons they might hate us.
    It's difficult to judge what Harris is advocating with this book. It's clear he rejects religion in the government affairs, but the extent to which his views go beyond this are not as clear. One might get the feeling reading the book Harris is advocating a wholesale rejection of religion all together. I don't think this is such a good idea because it conveys the idea atheists are against people of faith. I am not against people of faith--I just don't share their view. And the last thing I want is to get a large group of religious people thinking we atheists are against them. I don't think Harris is really advocating that atheists should walk around trying to convert Christians anyway, but I can't be sure and it's worth noting this point.
    Pictured is a honey oatmeal bread with a 4-strand braid and egg white glaze.  If it looks pretty tasty it's because it is :)

2 comments have been made.

From Nathan

chicago

October 22, 2007 at 1:45 AM

I'm doing a group project in my Social Bases of Behavior class. Each group has to choose a particular group of people, and we chose atheists (i tried anarchists first, but didn't quite have the support...you should be proud). Just have to define the group as well as possible (not that easy considering the various motivations, etc.) and discuss some social psychology issues (propaganda, conformity, prejudice, etc.) Seems like you might be a good person to ask if you know of anything that might be useful. Specifically some reputable sources to show the discrimination and misplaced blame on atheism for school shootings, etc. I can quote foxnews, but they hate anyone not just like them, not specifically atheists... Damn that bread sounds and looks good. U have a recipe for that? I've been itching to try making some bread lately. My school is hosting a "diversity dinner", organized by a small group of which I'm a member. My job was to find a Jamaican place to deliver some stuff to the school. They have a sweetbread called Festival that I want to try also. Yum.

From Andrew Que (http://www.DrQue.net/)

Wisconsin, USA

October 22, 2007 at 9:11 AM

Nathan -
Some sources I'd recommend:
   "Atheists identified as America's most distrusted minority, according to new U of M study"
   ReligiousTolerance.org
   A Brief History of Disbelief (BBC documentary)
Each of these is a good source for the kind of information you're looking for. The first gets right to the point: Americans distrust atheists. Religious Tolerance org is a decent site with a lot of information, and they cite sources. The documentary is about 3 hours long, but one of the primary themes that runs throughout is how atheists have been disliked throughout most of history. You might also have a look at how "In God we trust" ended up printed on money, since it shows how people tied atheism to communism.

October 19, 2007

Breaded Bread

    Today I decided to try braiding a loaf of bread.  I've been doing fairly well at making a decent tasting bread.  Now I want to experiment with an aesthetic bread.  This is a simple 3 strand braid.

Breaded bread about to rise

Breaded bread after rise

Bread after egg white glaze

Bread after coming out of the oven

    I'm pretty happy with the results, but I think I can do better.

1 comment has been made.

From Mazface

Wisconsin

October 23, 2007 at 5:04 PM

Mmm...Bread.