named_scope :open, lambda{|at_time| {:include => [:operation_hours],
:conditions => ["
# // FIRST OPEN TIMES DURNING THE PRESENT DAY
( operation_hours.open_time <= :compare_time
and operation_hours.close_time >= :compare_time
and operation_hours.open_day_id = :day_id
and operation_hours.close_day_id = :day_id
)
OR
# // OPEN PREVIOUS DAY AND EXTEND INTO THE EARLY MORNING
(
operation_hours.open_day_id = :day_id -1
and operation_hours.close_time >= :compare_time
and operation_hours.close_day_id = :day_id
)
# // FINALLY OPEN TILL LATE TOMORROW
OR
( operation_hours.open_day_id = :day_id
and operation_hours.open_time <= :compare_time
and operation_hours.close_day_id = :day_id +1
)
", {:day_id => OperationHour.parse(at_time)[0].to_i,
:compare_time => OperationHour.parse(at_time)[1]} ] }}
Thursday, August 5, 2010
Hours of operation aint that fun!
I geeked out for a while and worked on hours of operation named scope called 'open'.... This was a beeoych but in the end I kicked it's ass!
Monday, August 2, 2010
fulll circle geo/gis
So I have been geeking out with the Geo location stuff for about six months. So far I have played with mysql's geom//multi/poly/point and postgres multi poly/point...as well as lat/lng searching using geokit,
My inclination was to use Mysql as it is drop dead simple to set this stuff up...but it doesnt seem to work very well with GeoRuby or PostGIS. I think I read somewhere that Mysql can work with postgis but I couldn't get ita working.
So I tried Posgresql/PostGIS and I really liked it. Postgres as a database is pretty kick-ass and coming from a mostly mysql background I was pleasently suprised at the simplicity. Ok there are some subtle differences...
Then I started getting into using Sphinx with geo and ran into some wierd problems... It seems like a good idea but... I couldn't get it to work right. I even posted my problems on the group and didnt get a response (so far)...
I started having problems with postgres's ordering thru associations...wierd things started happening where it just wasnt sorting correctly....so to makw a long story short.. I just switched back to mysql as I am using geokit (lat/lng) for everything anyway... Lets see were this gets me!
My inclination was to use Mysql as it is drop dead simple to set this stuff up...but it doesnt seem to work very well with GeoRuby or PostGIS. I think I read somewhere that Mysql can work with postgis but I couldn't get ita working.
So I tried Posgresql/PostGIS and I really liked it. Postgres as a database is pretty kick-ass and coming from a mostly mysql background I was pleasently suprised at the simplicity. Ok there are some subtle differences...
Then I started getting into using Sphinx with geo and ran into some wierd problems... It seems like a good idea but... I couldn't get it to work right. I even posted my problems on the group and didnt get a response (so far)...
I started having problems with postgres's ordering thru associations...wierd things started happening where it just wasnt sorting correctly....so to makw a long story short.. I just switched back to mysql as I am using geokit (lat/lng) for everything anyway... Lets see were this gets me!
Tuesday, March 23, 2010
Gunz For Hire
Rails has created a whole new set of guns and amo... I can literally change everything in a completely messed up system in a matter of hours!!
Thursday, March 18, 2010
Way Cool new tech!
So I was asked yesterday why I don't program in Python. The truth is I don't know much about Python and was not really interested back my days of Perl (96'-2002). It just seemed that Perl was much better in my opinion. But as CGI/Perl ran it course there were all kinds of new problems starting with convention. This is probably why so many people say that Perl is 'ugly' and crude. On the contrary, we were writing some beautiful OO Perl (or at least we though so at the time).
I am guessing that the natural migration progression from Perl would be to PHP. PHP seemed to be a more mature language for web programming. But it too lacked a framework (at least at the time I was programming it back in 2003). So we made a lot of crappy PHP programs [a few that are still in production at Oakley today].
Enter Ruby/Rails (for me in 2006). Man, what a refreshing feeling. It has really made programming fun again and the MVC Rails framework basically rules and just keeps getting better (look at Rails 3!).
So what's on the horizon? I think more javascript/html frameworks. I was looking at http://cappuccino.org/ this morning. This is really cool. Mustache (http://github.com/foca/mustache) looks interesting too. So many cool things going on right now and no better way to mesh them together than with Ruby/Rails!
I am guessing that the natural migration progression from Perl would be to PHP. PHP seemed to be a more mature language for web programming. But it too lacked a framework (at least at the time I was programming it back in 2003). So we made a lot of crappy PHP programs [a few that are still in production at Oakley today].
Enter Ruby/Rails (for me in 2006). Man, what a refreshing feeling. It has really made programming fun again and the MVC Rails framework basically rules and just keeps getting better (look at Rails 3!).
So what's on the horizon? I think more javascript/html frameworks. I was looking at http://cappuccino.org/ this morning. This is really cool. Mustache (http://github.com/foca/mustache) looks interesting too. So many cool things going on right now and no better way to mesh them together than with Ruby/Rails!
Sunday, June 21, 2009
Rails 1.91 and international chars...hmmmm
So I finally installed ruby 1.9.1 on my netbook. YEA! Thanks to Mike Greenly's blog post I can safely and easily switch between any ruby install. Very cool Mike --thanks!
So I have an interesting Fraud Detection app that I am working on that has a routine function that converts international chars into their US-ascii format. I am doing this because I am trtying to normalize the string itself. What is interesting is that I can't get it to work correctly without giving me this error...
invalid multibyte char (US-ASCII)
...
syntax error, unexpected $end, expecting tASSOC
'ÀÁÂÃÅĀĄĂ' => 'A',
This works just fine and dandy in 1.8.7 but breaks in 1.9.1...hmmm
A bunch of the gems I tried to install including mongrel don't seem to work correctly either. But this is just my first stab at this so more to come I'm sure. Not as easy as I had hoped though. Strange, seems like this is the overall feeling of the Ruby community. It just doesn't seem like many people are making use of 1.9.x.
So I have an interesting Fraud Detection app that I am working on that has a routine function that converts international chars into their US-ascii format. I am doing this because I am trtying to normalize the string itself. What is interesting is that I can't get it to work correctly without giving me this error...
invalid multibyte char (US-ASCII)
...
syntax error, unexpected $end, expecting tASSOC
'ÀÁÂÃÅĀĄĂ' => 'A',
This works just fine and dandy in 1.8.7 but breaks in 1.9.1...hmmm
A bunch of the gems I tried to install including mongrel don't seem to work correctly either. But this is just my first stab at this so more to come I'm sure. Not as easy as I had hoped though. Strange, seems like this is the overall feeling of the Ruby community. It just doesn't seem like many people are making use of 1.9.x.
Saturday, June 20, 2009
Let me take your crappy site and turn it into rails
Tuesday, June 16, 2009
Working for a big enterprise company is....
hmmm. Let me think of a adjective for this one. Let me start out by saying that I have been working for Oakley Inc. for the past 8 years as a tech-lead and a backend developer. In that time I have put out a gazillion fires, created webservices, set up webservers, written carts (in 3 different languages) and parsed the unparseable! The turnover here has been amazing and it seems it is me and one other guy, Rick, that are the only ones who have not left. Everyone I know who has left is SO happy they did!
It has got to the point where I am numb to pain. Sometimes I feel like the Mickey Rourke in The Wrestler as I am now working with guys like 10 years younger than me.
Maybe I just need a long vacation...
http://www.youtube.com/watch?v=Bh3XDMzcdtU
It has got to the point where I am numb to pain. Sometimes I feel like the Mickey Rourke in The Wrestler as I am now working with guys like 10 years younger than me.
Maybe I just need a long vacation...
http://www.youtube.com/watch?v=Bh3XDMzcdtU
Subscribe to:
Posts (Atom)
