Friday, December 19, 2008

Simple way to Draw a Circle with Google Maps

The Google Maps API doesn't provide a "draw circle" function for free, so you're left to your own devices to draw an approximation of a circle using the GPolyline object.

Here's a really basic circle drawing example adapted from the more complex example below. My simple example:

http://www.herculessolutions.com/GoogleMapsSimpleCircle.htm

The more complex example with dragable points and more:

http://maps.huge.info/dragcircle2.htm

Thursday, April 24, 2008

How does ChaCha make money?

I just found out about ChaCha.com and had one pressing question: "How does ChaCha generate revenue?". Well, I dutifully texted that question into ChaCha and got this response:

ChaCha earns revenue from advertising on its website and through its strategic partnerships. Please text more questions to answer! http://chacha.com/u/theyxbp3


I don't see any advertising on their site, so I guess I don't really buy that answer. I think the real answer is, "ChaCha doesn't generate revenue yet, but hopefully we will some day, somehow". Or maybe they're funded by phone companies for some reason?

Wednesday, March 26, 2008

ROW_NUMBER() Sucks?

Is it just me, or does the SQL Server 2005 ROW_NUMBER() function's performance suck? I always used to complain about SQL Server's lack of a LIMIT clause like MySQL has. I was thrilled when 2005 came out with the ROW_NUMBER() function.

When we switched to SQL 2005, I dutifully recoded the main search query to use the ROW_NUMBER() function, only to find out that it hurt performance by almost 3 fold! In addition, using ROW_NUMBER() doesn't give you an easy way to get the total number of records a query would return. (Helpful to display something like, "Viewing records 51-100 of 2,120")

I should put a caveat here: My testing shows that ROW_NUMBER() is actually much faster when doing very simple queries with large numbers of rows. For example, if you need to quickly grab 10 rows in the middle of all 10,000 rows in a single table with no joins, ROW_NUMBER() is probably for you. However, if you're doing a more complex query like to search for specific records or joining with many other tables, my testing shows ROW_NUMBER() is a significant slow-down. Here are the results for my specific query:

Description Rows Estimated Cost Actual Time Slowdown
My original query 12,547 3.701 0.729 -
Using ROW_NUMBER() 12,547 6.616 2.094 287.1%!

So, if not ROW_NUMBER(), then what? My solution is to declare a temporary table and insert all of your result IDs into that table, along with the ordering. You can then join with that table to grab only the results you need. For example:

DECLARE @FirstRecord Int
SET @FirstRecord=0
DECLARE @LastRecord Int
SET @LastRecord=49

--First make a table to hold the order of the final sorted results
DECLARE @ResultOrder TABLE  
(     OrderID int identity(0,1) not null primary key clustered,
    ResultID int    
);

--The main "search" query... this can be pretty slow with lots of rows
INSERT INTO @ResultOrder (ProductID)
    SELECT p.ProductID
    FROM Products p
    WHERE p.Cost < 100 AND p.CategoryID=4 --Or whatever search you're doing

--A very fast way to get the total number of results
SELECT COUNT(*) FROM @ResultOrder; 

--A very fast way to get the details... you can even join with many more tables
SELECT p.Name, p.Cost, c.Name AS CategoryName, s.Name AS SalesPerson
FROM @ResultOrder ro, Products p, Categories c, SalesPeople s
WHERE p.ProductID=ro.ProductID
    AND p.CategoryID=c.CategoryID
    AND p.SalesPersonID=s.SalesPersonID
ORDER BY ro.OrderID

Obviously, that is a simple example, but I suspect as your query gets more complicated (especially the 2nd details part) you're way better off not using ROW_NUMBER().

As an ADDITIONAL speedup, that first result set is potentially PRIME cacheing material. For example, if a user (or a crawler) hits the first page of results, then clicks "next" a few times. You do the expensive search only once, then quickly pull up the details for each page on subsequent requests. You might have to analyze your usage to see how often and how close together different pages of the same search are requested.

How do you best cache those Result IDs you ask? And how do you get the IDs to and from SQL? Well, I'm about to implement that myself so hopefully I'll let you know in a subsequent blog post.

Tuesday, March 18, 2008

TWL Two Letter Words Sorted By Second Letter

I'm playing a lot of scrabulous online lately and I constantly want to see which two letter words END in a given letter. So for your enjoyment, here are the 101 words defined by the TWL sorted alphabetically by first letter and second letter.
In list format:

Sorted by the first letter
AA AB AD AE AG AH AI AL AM AN AR AS AT AW AX AY
BA BE BI BO BY DE DO ED EF EH EL EM EN ER ES ET EX
FA FE GO HA HE HI HM HO ID IF IN IS IT JO KA KI LA LI LO
MA ME MI MM MO MU MY NA NE NO NU
OD OE OF OH OI OM ON OP OR OS OW OX OY
PA PE PI QI RE SH SI SO TA TI TO UH UM UN UP US UT
WE WO XI XU YA YE YO ZA
Sorted by the second letter
AA BA FA HA KA LA MA NA PA TA YA ZA
AB AD ED ID OD AE BE DE FE HE ME NE OE PE RE WE YE
EF IF OF AG AH EH OH SH UH AI BI HI KI LI MI OI PI QI SI TI
XI AL EL AM EM HM MM OM UM AN EN IN ON UN
BO DO GO HO JO LO MO NO SO TO WO YO OP UP AR ER OR
AS ES IS OS US AT ET IT UT MU NU XU
AW OW AX EX OX AY BY MY OY
And in table format:
Sorted by 1st letter Sorted by 2nd letter
AA
AB
AD
AE
AG
AH
AI
AL
AM
AN
AR
AS
AT
AW
AX
AY
BA
BE
BI
BO
BY
DE
DO
ED
EF
EH
EL
EM
EN
ER
ES
ET
EX
FA
FE
GO
HA
HE
HI
HM
HO
ID
IF
IN
IS
IT
JO
KA
KI
LA
LI
LO
MA
ME
MI
MM
MO
MU
MY
NA
NE
NO
NU
OD
OE
OF
OH
OI
OM
ON
OP
OR
OS
OW
OX
OY
PA
PE
PI
QI
RE
SH
SI
SO
TA
TI
TO
UH
UM
UN
UP
US
UT
WE
WO
XI
XU
YA
YE
YO
ZA
AA
BA
FA
HA
KA
LA
MA
NA
PA
TA
YA
ZA
AB
AD
ED
ID
OD
AE
BE
DE
FE
HE
ME
NE
OE
PE
RE
WE
YE
EF
IF
OF
AG
AH
EH
OH
SH
UH
AI
BI
HI
KI
LI
MI
OI
PI
QI
SI
TI
XI
AL
EL
AM
EM
HM
MM
OM
UM
AN
EN
IN
ON
UN
BO
DO
GO
HO
JO
LO
MO
NO
SO
TO
WO
YO
OP
UP
AR
ER
OR
AS
ES
IS
OS
US
AT
ET
IT
UT
MU
NU
XU
AW
OW
AX
EX
OX
AY
BY
MY
OY

Sunday, January 27, 2008

Back in Santiago!

After another all night, 12 hour bus ride we made it back to Santiago! Dan just left safely and should be in the air on his way to Chicago in a few minutes.

This is the point in my post where I like to complain about either the speed of the Internet or the speed of my computer. Today you are in for a treat because I get to complain about BOTH! I was hoping to upload all 200 or so of my photos, but they are taking about 5 minutes each. There will be a few up, but I think we'll have to wait for later to see all of them. There are also some exciting VIDEOS on the way!

Today in Santiago, we got in, helped Jess finish moving out of her apartment, found a place to stay and explored the city! Tomorrow we may be hitting up two coastal cities about an hour from here, Valaprasio and Vina del Mar.

I'll post more photos and videos soon! You can see my Chile set of photos in progress here:

http://www.flickr.com/photos/jerschneid/sets/72157603748636020/

Saturday, January 26, 2008

3 Days In Bahia Inglesa

We spent the last 3 days and 2 nights in Bahia Inglesa! Bahia Inglesa (or English Bay) is this gorgeous little touristy beach town. Food and lodging is expensive, but totally worth it because everything there is so beauiful and sunny. I think we all could have used about an extra week there!

Unfortunately, I´m currently using the same computer that the Wright Brothers used to run their aviation simulations. The historical value is interesting, but uploading photos is nearly impossible (as it pre-dates the Internet by about 80 years).

The last two days we went SURFING on the Pacific coast! We wore wet suits as the ocean is still pretty cold here, but not too bad. This was my first time surfing and I did a bit better than I expected (although I had pretty low expectations, since my goal was to not drown). It turned out it is pretty easy to "catch" a wave, but standing up on the board proved to be the hardest part... I got up a few times but nothing you´ll see on ESPN2 any time soon.

We also stayed in this awesome little cabaƱa. Well, not little, actually. It had 3 rooms and SIX beds, plus a living room and kitchen and porch! We bought groceries and cooked dinner and drank Chilean wine last night. I think they charge per person, and foreigners don´t have to pay the 19% sales tax so we ended up paying about $80 per night, split 3 ways!

Tonight, we´re catching an overnight bus to Santiago. Dan leaves tomorrow and Jess and I leave on the 29th. I´ll be back in Michigan on the 30th! Photos and even some exciting VIDEOS will follow!

Wednesday, January 23, 2008

On our way to Bahia Inglesa!

We´re doing great and have left San Pedro de Atacama. We're currently on a layover and are on our way to Bahia Inglesa which is described as "beach nirvana". Still short on Internet time, but here are a few selected photos from the last few days!

Chile 001
Here we are in our beach clothes in 0 degree Weather! Actually, this is after the sun came up, so we were much warmer here.

Chile 002
Here is a shot of the mountain where we saw the geysers. Those are flamingos!

Chile 003
This is my feet as we are about to cross the Bolivian border. I didn´t sign up for snow!

Chile 004
Dan and I in the snow. SNOW? Seriously though... I didn´t sign up for snow.

Chile 005
This is a shot of the Bolivian customs building, which was more of a shack. To get here, we turned off of a nicely paved highway in what seemed like the middle of nowhere. I don´t even think we were on a road. We just drove off road for a while then got to this shack. (They did have two little gates, also in the middle of nowhere, as if that might prevent people from crossing or something). We actually had some trouble crossing. They said Americans had to get visas in advance, even though our tour booking guy specifically said we didn´t. Everyone else on our tour left and we were sitting there at this shack in the middle of nowhere, waiting for the Bolivian "boss" who was going to come sort it out. He actually did show up, and got us temporary visas. I have to imagine the tour company decided it was easier to have their guy bribe the officials rather than force American tourists to buy the expensive and time consuming visa. It would have been nice to let us know though!

Chile 006
The three of us in Bolivia in front of La Laguna Blanco

Chile 007
We drove around in Bolivia in these trucks for HOURS and HOURS and HOURS over virtually no roads. We all had serious headaches and car sickness by the end of the day. We also were in a BLIZZARD by the end and were concerned that we wouldn´t make it back at all. I certainly did not sign up for a blizzard.

Chile 008
Dan and Jess in natural hot springs in the middle of the Mountains! The hot springs were about 100 degrees here!

Chile 009
This photo doesn´t do this place even a little bit of justice, but it is a huge bright PINK lake with THOUSANDS of pink flamingos in the middle of gorgeous mountains. It was just really really beautiful, fertile land. Amazing stuff. And if you´re wondering how flamingo kebabs taste, they´re delicious.


Monday, January 21, 2008

Still Having Fun in San Pedro DE Atacama!

Today was a BIG day here in the "driest" desert in the world! Last night was actually capped off with RAIN here in the driest desert in the world. To be honest, we are not that impressed with the dryness. I´ve seen drier.

Last night was CLOSELY followed by this morning which started with a 3:15 am wake up call. That´s not "Chile" time where an hour is actually 4 hours or anything, Jessica actually made us drag our asses out of bed at 3:15 am. We did this to hit the Tatio Geysers in the best viewing time of between 6 and 7 am.

Our helpful tour booking agent informed us that these are HOT geysers that include a hot springs for bathing so we should make sure to bring our swim suits. Dan, Jess and I diligently dressed in flip flops, bathing suits and long sleeve t-shirts and our light jackets (in case it was cold). One point of interest was the native´s choice of clothing. While we chose "beach wear", they seemed to prefer parkas, long pants, scarves and hats. Apparently, when you are 5200 meters above sea level, in the desert, before the sun rises, 0 celcius is a pretty average temperature. We continually asked if we were in the right place for the beach volleyball tournament, but no one knew what we were talking about.

The geysers were hot, both literally and figuratively. We DID get in a swim after the sun came up! Our trip was capped by seeing some real live mountain llamas! Our guide then took us to a tiny local town where they were selling real dead llama-kebabs. He seemed to think it was hilarious to point towards the llamas and say "before" then point to the grill and say "after". If you are wondering how llama-kebabs taste, they are delicious.

Also: we went to the moon valley. We´re on a dial-up connection so more details and photos will follow! Tomorrow, we are heading to BOLIVIA, then a bus to Bahia Inglesa on Wednesday! I suspect they´ll have better Internet there.

Sunday, January 20, 2008

We're in San Pedro de la Atacama

After a 17 hour bus ride, we have made it to the Northern most point of our trip, San Pedro de la Atacama. The "Atacama" is the driest desert in world! Although, to be honest, I'm not that blown away by the dryness just yet.

The highlight of the bus ride was playing some mad boggle on the last leg (Jessica remains undefeated). The lowlight was the poop smell that engulfed us everytime another wayward passenger decided to venture into the unknown of the bus urinal. I personally made it all 17 hours with no potty breaks! Go blue!

Tomorrow we're getting up at FOUR AM to check out these geysers and hot springs and then doing a sunset trip to this famous valley area in the desert. The NEXT day we're going to Bolivia on a lake tour! That means I get one step closer to Jessica in terms of countries visited (proportionally, at least)

The Internet connection sucks here so no photos today! Hopefully in our next city! We'll be here for three nights, then off to Bahia Inglesa.

Saturday, January 19, 2008

In La Serena, Heading to San Pedro

We have finally made it on our way! We made the tough ¨Go North/Go South¨ decision based on a series of thougtful discussions, a few coin flips and a rousing game of rock/paper/scissors. We decided to head NORTH!

After one night in Santiago, we took a morning bus to La Serena, which is about 6 hours north. We checked out the beach, went to a nearby town and hiked up a mountain and last night we had a midnight trip to an observatory. Chile, according to our guide, is the best place in the world for observatories and coutries from all over the world are building telescopes such as the VLT (Very Large Telescope), the ELT (Extremely Large Telescope) and the OWL (OverWhelmingly Large).

We´re headed to San Pedro tonight on an overnight 14 hour bus ride. Apparently it is the driest dessert in the world. I´m skeptical... I think I´ll be able to spot a FEW puddles, at least... I mean, how dry can it be? My computer time today is pretty short so I think I´ll end it here with some photos!

You can see my photos here http://www.flickr.com/photos/jerschneid/

Imagen 025

Imagen 001

Imagen 010

Imagen 033

Wednesday, January 16, 2008

Made it to Santiago!

So I have finished the first part of my journey and made it to Santiago, Chile! I stopped in Atlanta, then a 10 hour flight to Santiago! Chile is actually 2 hours AHEAD of New York and 5 hours ahead of the West coast.

This is my first time in the southern hemisphere. Things are not nearly as upside-down as I imagined. Also, it's summer here, which would have been helpful knowledge to have before I packed. Oh well...

Ok... Short on time today but more posts and photos to come!

Wednesday, January 02, 2008

FullSizePosters Review

I recently was looking for a way to print a reasonably high quality 24 x 36 inch poster to be placed in a frame in my living room. I checked out a ton of options, including getting ripped off by your local Kinkos or the vast array of online stores that claim to do it.

I finally decided on FullSizePosters.com. I made the decision based on their great prices, their focus on poster printing and a good feeling I got from the positive reviews on their site along with their phone number displayed at the top of every page. (I had read some horror stories from other printers where the print didn't show up for weeks with no way to contact the company)

The actual upload and checkout process was really nice. The site is strikingly simple, only a couple pages, but it's exactly what you want and need. They make really good use of Google checkout. I paid easily and quickly got a receipt by e-mail with a link to track the status of my order.

I placed the order around 1:20pm on December 28th and was thrilled that it was printed and shipped THAT DAY. They shipped via USPS 2-3 day priority mail with a reasonable shipping cost. (I paid $32.37 when all was said and done for my 2x3 poster)

I received my poster 2-3 business days later. It came in a really sturdy cardboard tube. Inside the tube, my poster was rolled in tissue paper and sealed in an airtight plastic bag.

The poster looks awesome. I mean... it's perfect. I've gotten used to being disappointed after ordering a print job, but this final product was exactly what I hoped for. The print is on really high quality glossy photo type paper. Kind of like a big version of a photo you might get developed, so it's thicker and heavier duty than a stock poster you would buy at the store.

ANYWAY, I was googling for "FullSizePoster Reviews" when I was making my decision, so hopefully this is helpful to others. Also, FYI, this is not a paid post of any kind. I'm just a dude trying to give back to the Internet community in my own little way. Thanks FullSizePosters.com! :)

P.S. The poster was actually to play a prank on my roommate. Here is what I printed:

Catface couch final