March 2004 - Posts

Zip.NET

I was enhancing my mp3 aspx search page to include a shopping cart function. I figured it would be nice to grab all of the mp3 files, zip them up into one big zip file and dump it into the HTTPResponse stream. Well two missing things: A zip library and a way to stream in the files so I don't have to create an actual hard disk based zip file. Here's how I did it:

The zip library can be found here -- SharpZipLib It's open source and a byproduct of the very cool open source SharpDevelop IDE.

Here's the code:

MemoryStream ms = new MemoryStream();
ZipOutputStream s = new ZipOutputStream( ms );
s.SetLevel(5); // 0 - store only to 9 - means best compression

foreach ( int id in ids ) // primary key ids
{
 
string location = new MP3DataAccess().GetLocation( id );
 
FileInfo fi = new FileInfo( location );
 
FileStream fs = File.OpenRead( location );
 
byte[] buffer = new byte[ fs.Length ];
 
fs.Read( buffer, 0, buffer.Length );
 
ZipEntry entry = new ZipEntry( fi.Name );
  s.PutNextEntry( entry );
 
s.Write( buffer, 0, buffer.Length );
}

s.Finish();
int streamLength = (int)ms.Length;
ms.Seek( 0, SeekOrigin.Begin );
ms.Position = 0;
byte[] buffinal = new byte[ streamLength ];
ms.Read( buffinal, 0, streamLength );
ms.Close();

Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/octet-stream";
Response.AppendHeader( "content-length", streamLength.ToString() );
string uniqueFileName = "mp3s-" + DateTime.Now.ToString( "yyyy-MM-ddTHHmmss" ) + ".zip";
Response.AppendHeader( "content-disposition", "inline; filename=" + uniqueFileName );
Response.BinaryWrite( buffinal );

Posted by craigg75 with 6 comment(s)
Filed under:

Poster children

Ok the story goes like this. This big chief the Palestinian terrorists follow was killed by an Israeli helicopter gunship the other day. That same day a lamb was born with the markings of the word Allah on it (in Arabic letters). So the retards think it's religiously significant. Big woop, I see all kinds of stuff in the clouds but realize like most people the power of coincidence. Why don't we make these guys poster children for a better world? Here's my attempt at it --

Posted by craigg75 with 1 comment(s)
Filed under:

Its raining again

I love springtime because it rains all the time. I should live in Seattle, I don't get enough of it. Of course then I'd probably hate it. Spock said it best in Amok In Time - “After a time, you may find that having is not so pleasing a thing, after all, as wanting. It is not logical, but it is often true.“ What's with all the Star Trek quotes lately? Ah rain rain rain.. I was real close to taking today off just so I could walk around in the rain....
Posted by craigg75 with 2 comment(s)
Filed under:

Eternal Sunshine of the Spotless Mind

Annette and I saw the latest Jim Carey movie, Eternal Sunshine of the Spotless Mind last weekend. It was ok, not bad and not good, just average. Annette thought it stunk, but she's not a big fan of Jim Carey and came in with that pre-judgement. He played a real shy guy without any of his usual wackiness though. I found a new appreciation for Kate Winslet. Something extremely attractive about her in that movie. For all you Kirsten Dunst fans there's a great scene of her jumping up and down on a bed in her underwear. Anyway the plot of the movie is Carey's character and girlfriend (Winslet) erase their memories of their shared but stormy relationship. Jim Carey backs out in process and we discover how memory works. Nothing new really. Anyway the question obviously is would you erase a part of your memory if you could? In the words of Captain Kirk “Damn it, Bones, you're a doctor. You know that pain and guilt can't be taken away with a wave of a magic wand. There the things we carry with us, the things that make us who we are. If we lose them, we lose ourselves. I don't want my pain taken away. I need my pain.“ I think most people agree with Kirk there. I think there is one thing I'd like erased from me. My memory of the movie The Fly with Jeff Goldblum. That movie still haunts me. Left me with some serious creeps way down deep. It serves no purpose other than to turn my stomach whenever I see Jeff Goldblum. But like roadkill or Doritoes I can't stop watching it when it comes on tv (f*ck you Ted Turner for showing that movie all the time). I'm drawn in by it's total “grossness“. At every turn I keep thinking, this movie can't get any more gross and then Jeff Goldblum barfs up acid to dissolve his food. Not only did he pull his ear off, he's stores it in a cabinet with all his other lost body parts. Ahhh!!!!
Posted by craigg75 with 5 comment(s)
Filed under: ,

Top albums

While I'm on the subject of lists here's my favorite albums of all time. My own personal restriction is Greatest Hits albums are not allowed. All albums must be listenable all the way through. All songs must be good. Looking at these albums they are complete works of art to me. Not an attempt, like most albums, as a way to get a quick hit out and fill the rest with “filler“.

AC/DC - Back In Black
Aerosmith - Toys In The Attic
Eagles - On The Border
Beatles - Sgt Pepper Lonely Hearts Club
Beatles - Abbey Road
Boston - Boston
Def Leppard - Pyromania
John Denver - Rocky Mountain High
Dan Fogelberg - The Innocent Age
David Gilmour - About Face
Peter Gabriel - So
Genesis - Foxtrot
Genesis - Selling Englang By the Pound
Goo Goo Dolls - A Boy Named Dizzy
Sammy Hagar - Standing Hampton
Stuart Hamm - Kings of Sleep
Steve Howe - Quantum Guitar
Jethro Tull - Aqualung
Kansas - Monolith
Marillion - Misplaced Childhood
Nektar - Remember the Future
Ted Nugent - Cat Scratch Fever
Planet P Project - Pink World
Pink Floyd - Dark Side of The Moon
Pink Floyd - The Wall
Pink Floyd - Wish You Were Here
Pink Floyd - Animals
REO Speedwagon - T.W.O
REO Speedwagon - Hi Infidelity
Rush - Moving Pictures
Rush - 2112
Rush - Farewell To Kings
Rush - Hemispheres
Rush - Permanent Waves
Bruce Springsteen - Born To Run
Styx - The Grand Illusion
Joe Satriani - The Extremist
Santana - Inner Secrets
Shooting Star - Shooting Star
Shania Twain - Come On Over
Third Eye Blind - Blue
Touch - Touch
Triumvirat - Spartacus
Triumph - Allied Forces
U2 - The Unforgettable Fire
Yes - Drama
Neil Young - After the Gold Rush

Posted by craigg75 with 1 comment(s)
Filed under:

Books that have influenced me

Ok so I took a month off from blogging. Ran out of stuff to say I guess.

Anyway there's a good post on kuroshin about what books have influenced you the most. Good stuff out there to read, too many books and not enough time as usual. Thank god for audio books so I can multitask books while driving, working out or any other low brain use activity. I've actually “read” quite a few books this way just this year. Ok so here goes the list --

1984 - George Orwell - Let me start off by saying I had to read this book in high school. This book was my first political book. It made bells and whistles go off in my head. I think it hit home how organized groups of people, be they goverments, corporations or cults stay in power at any expense, even if it means destruction of a person's soul. The concepts of doublespeak, newspeak and goverment boogey men have stuck with me always.

Earth Abides - George Stewart - A post-apocalyptic book that hammered home how fragile our civilization is and how much I rely on it for happiness. The protaganist grew old and really gave me insight into what demetia was like. I think it was the first time I realized that getting old can suck. I also think it was the first time I felt what it must be to suffer real loss, not only of everything you know but of your mind too.

Broca's Brain - Carl Sagan - I was a Carl Sagan fan early on with his Cosmos tv show. So I naturally picked this book up and read it. I think this book made me realize that we may call ourselves humans but we are still animals that are constantly wrestling with the parts of our brains that had their use in our early evolution. It amazed me to find out that there's a deep rooted reptilian portion of brain that is responsible for anger and violence. To know that we are “hard wired“ into these behaviors left me well.. hard wired.

Cat's Cradle - Kurt Vonnegut - I was falling asleep downstairs at my college's library on a big comfy couch when I peered the bottom shelf, a whole row of Kurt Vonnegut books. Well I enjoyed the Slaughterhouse-Five movie so what the hey I picked up the smallest of the books, Cat's Cradle. It was my first experience with brutal sarcasm in a book. To view the human race as nothing more than bags of water that can freeze and the same as rocks when it comes to physical laws was enlightening. With our “gifts“ of consciousness, civilization, conquering nature, etc. we still are just a speck in cosmos. Is there no one that really cares about us other than ourselves?

Childhood's End - Arthur Clarke - This was the first scifi book I read that completely blew me away. I was hooked ever since then.

Minds Machines and Evolution - James Hogan - This book expanded my mind by starting me on the path of answering some of the more difficult questions like what is the mind and consciousness. The idea that our consciousness is just an emergent property of the brain blew me away. I've been applying the emergent property concept ever since then to other things. I think at this point I officially became an atheist, there was no point to having a god in the universe to me. There is no god, there are only gears.

Leaves of Grass - Walt Whitman - Not sure where I picked this up from. I decided to try out poetry and absolutely loved this guy. I never much cared for poetry that was forced on me in school so I had my reservations. But this was unbelievable to me how well someone could explain America in the 19th century, almost like I was there. I really got the idea that a poet describes the indescribable. I've never read other poets that I've liked as much as Walt Whitman.

The Conscience of a Conservative - Barry Goldwater - I think what struck me a chord with me here is that politics is not all fluff or a big game. That there is an argument that certain political systems may actually be more natural to human beings than others. The concept that capitalism is apart of our being in that it's a survival of the fittest thing was very cool to me at the time. It made me go and investigate other political idealogies like communism, anarchism, socialism, etc.

Anarchy - Unknown - I lost this book some time ago. It was closely related to the above book. This was my first introduction to libertarianism and it's ideals. Also it sealed for me that all political systems are not perfect but a best fit situation. Living under no goverment is great on paper but lousy in practice.

The Hobbit - J.R.R. Tolkein - My first real book I ever read. It didn't influence me too much other than gave me the bug to continue reading more books.

The Gospel According To Jesus Christ - Stephen Mitchell - I think I finally got it that the Christian religion was created not to spread the word of Jesus Christ but to take advantage of the god concept built into people. This book reinforced in me that the New Testament was editted to fit the purpose of the authors. Also that Jesus was a gifted man and not a god, that was way before his time.

Sarum - Edward Rutherford - This book sent me on my way to becoming a full fledged anglophile. English history continues to amaze me. I can say that I'm proud that our heritage comes from England.

Vietnam - Stanley Karnow - Written by a war correspondant. At the time I was fascinated with what happened in our country during the 1960's. The cultural upheaval the ensued after JFK. I was drawn into this book from a series that ran on PBS that was based on this book. I came away with the dreadful feeling of the cultural and personal losses that a war causes. I was impressed with the North Vietnamese and Vietcong and how strongly they held a belief in unifying their country. How they were willing to lay down their lives for that cause. They first fought the French and then the Americans for many long years. You would think at some point our leaders would have come to the conclusion that these are not evil people with evil intent but true patriots wanting to try out a system of goverment that they think is best for everyone. Well the world was different then. But has it changed? Anyway I came away with a totally different viewpoint of Vietnam.

A future book I believe will be amazing is -

Godel, Escher and Bach - Douglas R. Hofstadter

Posted by craigg75 with 4 comment(s)
Filed under: