Technology Games News

My personal blog

Date Functions

Hi All,

I've changed this slightly and would like your opinion on it. Here is what i am trying to achieve.

- A weekly report to be produced every Sunday.
- The start date is the first day of the week
- The end date is the last day of the week
- The start date cannot be a day in the previous month. For example if the Sunday falls on the 3rd day of the week (e.g. 3rd June 07), the start date will be the first day of the month.
- The End date cannot be a day in the next month. For example, if the Sunday falls on 2nd day of the next month (e.g. 24th June 07), the end date will be the last day of the current month (i.e. 30th of June).

This is what i've come up with and would like your opinion or comments on whether you think i might have missed some (orphaned) days or whether the method i chose might be wrong.

Thanks in advance.

  -- Check if its Sunday or last day of month  IF To_Char(SYSDATE, 'DAY')='SUNDAY' OR (TRUNC(sysdate) = TRUNC(LAST_DAY(sysdate))) THEN    -- Get Start date of report    -- Check that the start date is not on the previous month    IF (To_Char(SYSDATE, 'DAY')='SUNDAY') AND TRUNC((SYSDATE)-6),'MM')=TRUNC(SYSDATE,'MM') THEN      -- not gone to previous month      lv_start_date:=TO_DATE(SYSDATE)-6);    ELSE      -- gone to previous month so just use first day of the month      lv_start_date:=TRUNC(SYSDATE,'MONTH');    END IF;      -- Get end date of report    -- Check that the end date is not on the next month    IF (To_Char(SYSDATE, 'DAY')='SUNDAY') AND (TRUNC(sysdate) <= TRUNC(LAST_DAY(sysdate))) THEN      -- not gone to next month      lv_end_date:=SYSDATE;    ELSE      -- gone to next month so just use last day of the month      lv_end_date:=TRUNC(LAST_DAY(sysdate));    END IF;      -- Run report    stats_package.producestats(lv_start_date,lv_end_Date);  END IF;  



Elemental: Conditional Content with CakePHP

I finally got around to implementing conditional content here on Snook.ca. I've wanted to do this since I moved to the new design just over a month and a half ago. The left sidebar has a number of elements like the projects I've worked, quick links, etc. As some people have noticed, if the article was particularly short, the comments would often overlap the rather lengthy content. I didn't want that.

With a little bit of late night development and some quick help from Larry (aka PhpNut, the lead developer of CakePHP), I've developed what I have dubbed "Elemental".

Elemental

Elemental consists of 2 parts: some new controller methods added to app_controller.php, and a new helper called Elemental.

In app_controller.php add:

    function enableComponent($component, $params=null)
{
$name = Inflector::camelize($component);
$found = loadComponent($name);
if($found)
{
$cn = $name . 'Component';
$comp = new $cn($params);
$comp->startup($this);
$this->viewVars['elements'][$component] = true;
}
}

function enableElement($element)
{
$this->viewVars['elements'][$element] = true;
}

function disableElement($element)
{
$this->viewVars['elements'][$element] = false;
}

The methods enableElement and disableElement will turn on or off whether a particular element should be displayed in the view. The method enableComponent takes the extra step and conditionally loads a component and enables the related element that goes along with that.

To use the element in your view just do:

echo $elemental->load('projects');

In this particular example, it calls the projects.ctp element. This should work exactly like $this->renderElement but will only load if the element has been enabled using enableElement or enableComponent..

Here's the Elemental helper:

<?php
class ElementalHelper extends Helper {
function load($element, $params=array())
{
$view =& ClassRegistry::getObject('view');
if(isset($view->viewVars['elements']) &&
isset($view->viewVars['elements'][$element]) &&
$view->viewVars['elements'][$element])
{
return $view->renderElement($element, $params);
}
}
}
?>

Using it on Snook.ca

What I've done on Snook.ca then, is to break up the sidebar into a few different elements. All elements are enabled by default via the app_controller. Then, in my posts controller, I check the length of the body element and disable elements as the article gets shorter. Here are some examples:

I can now keep the sidebars light and avoid overlap or throw in some bonus material if the article is longer.


REPORT: ApolloCon 2007, Day 3

REPORT: ApolloCon 2007, Day 3 The final day at ApolloCon . Today was a shorter day than day one or day two . I was a bit worn out today, so my participation level wasn't up to previous days. On the bright side, I met up with local author Larry Ketchersid and got to say hi. My first session was Size Matters! Knowing or Choosing the Correct Length to Tell Your Tale with ... (Read on Source)


Chu Lin ya tiene sucesor

La muerte de Chu Lin conmovió a la sociedad española hace 11 años, después de ser un icono para el Zoo de Madrid...


SEO Chat Forums - Content indexing in 40 minutes - record?

Date: August 26th, 2007 07:18 AM - Glenn Kilpatric - Untitled Post: This is some great news. I would try updating a blog of mine and ping. I'm hoping for the same results. ;) Mostly my blog topics go supplemental dam fast too. Too fast infact....


Mayweather may dance with the stars

In the wake of the success of Darren Gough and Mark Ramprakash in 'Strictly Come Dancing', it appears that Ricky Hatton's opponent Floyd Mayweather may be on the verge of showing his twinkle toes outside the ring on American television. Mayweather is on the shortlist for the TV series 'Dancing With The Stars', the US equivalent of 'Strictly Come ... (Read on Source)


Ubuntu, Kubuntu 7.10 Beta Released

The Ubuntu team has released the beta for Ubuntu 7.10, Gutsy Gibbon. Highlights include GNOME 2.20, fancy desktop effects through Compiz Fusion, and more. Kubuntu 7.10 beta has also been released, featuring Dolphin as the default file manager, a restricted drivers manager, and updates and polish across the board.


East-West Tech Transfer: The Greening of IT, Part 1

The sharing of new technology is taking place faster than ever before, yet economics, political and socio-cultural differences, vested interests and national agendas remain obstacles constraining the potential benefits. To a greater degree than in previous decades, commercial organizations and governments are being challenged to address economic, social development and environmental needs at the same time.


Capitol link in Washington

Here's how area members of Congress voted on major roll calls last week: House WAR FUNDS, IRAQ PULLOUT: The House voted 218-203 on Wednesday to send the Senate a bill that couples $50 billion in war ... via Arizona Daily Star


Living on Mars Time: Scientists Suffer Perpetual Jet Lag

Living on Mars Time: Scientists Suffer Perpetual Jet Lag Morten Bo Madsen spends his work day crunching data on a laptop seated in front of a clear plastic-covered box about the size of a widescreen computer monitor that emits a startlingly bright blue light. (Read on Source)


Fusion 2.0 Beta 2 Available

Beta 2 of VMware Fusion 2.0 is now available, and boasts a significant number of new features and improvements that make it a great solution for virtualization on Mac OS X.


Delta to Become Only Major U.S. Airline to Offer Broadband Wi-Fi Access on Entire Domestic Mainline

... and PDAs, can surf the Web, check any e-mail, Instant Message, access their corporate VPN and more. Plus, Gogo includes free access to valuable online content from The Wall ...


DeLorean car sought for performance

A venue has promised to make an iconic 1980s vehicle the centre stage for a performance of a critically acclaimed concept album.


Counterfeits Lurk Among Online Discounts

Research by OpSec Security, a global brand protection and anti-counterfeiting company, found that on average, online auction sites were discounting popular back-to-school items at approximately twice the rate of discounts offered by authorized online retailers. Deeply discounted pricing for new, back-to-school items is sign that counterfeiters ... (Read on Source)


Nada is new station manager

... development studies at the Nelson Mandela Metropolitan University. Her career in broadcasting started at Ubuntu Community Radio in 1997 where she received training in various areas. In 1998 she ...


College reviews - by college students

College reviews - by college students I'm partial to hearing from young Internet enterpreneurs, like Jordan Goldman, the 23-year-old founder/CEO of Unigo.com who contacted me today and whose site was featured in last week?s NY Times Magazine. Excerpt: (Read on Source)


Rhombus acknowledged at 2008 China Hotel Industry?s Leaders Summit

Rhombus acknowledged at 2008 China Hotel Industry?s Leaders Summit.


Kenya Uses Text Messages To Track Elephant

Kenya Uses Text Messages To Track Elephant Kenya is the first country to try elephant texting as a way to protect both a growing human population and the wild animals that now have less room to roam. (Read on Source)


Maxtor's Central Axis

Add a centralized, always-available terabyte of storage to your local network.
Add to digg Add to Reddit Add to Slashdot Email this Article Add to StumbleUpon


Daniel R. Harris/Icon SMI - CNN International


Bleacher Report

Daniel R. Harris/Icon SMI
CNN International - 30 minutes ago
Oregon State kicker Justin Kahut's game-winning field goal against Arizona on Saturday sent a ripple across the entire bowl landscape.
Bowl projections: Texas has easiest road to title game SportingNews.com
Will BCS Snub Boise State? It Has Happened Before and It Will ... Bleacher Report
FOXSports.com - Salt Lake Tribune - Boston Globe - San Francisco Chronicle
all 74 news articles


Install Nagios 3 on Ubuntu 8.10

BeginLinux: "Nagios is a free, open-source tool that can be used to monitor network components and services. When it detects a problem, it can send alert messages by either e-mail or pager. It can also be configured so that only designated personnel can view status information for particular services or equipment. This tutorial will show you how to install Nagios 3 on an Ubuntu 8.10 server."


Open Source 'Fundamentally Superior': Red Hat CEO James Whitehurst

In January, James Whitehurst became president and CEO of Raleigh, N.C.-based Red Hat. The 41-year-old came to the software company, which sells and services the Linux open source computer operating system, from Delta Air Lines, where he was chief operating officer and had worked on, among other projects, development of the discount travel Web site Orbitz.


Felix Liao: Search Blogger of the Day

Felix Liao: Search Blogger of the Day Meet Felix Liao, the Search Blogger of the Day. Today I'd like to highlight a post called How To Find Your Answer In Other People's Discussions . Felix focuses on writing about alternate search engines, and this one could be very useful from both a social networking and content creation point of view. (Read on Source)


Ailing Economy Not Expected to Derail Iridium Deal

GHQ shareholders seem no less favorable to the Iridium purchase. (Read on Source)


7Seas Technologies bags Best Game Site' Web Award for its online gaming portal www.onlinerealgames.c

... Staffed by volunteers, this organization is made up of marketing, advertising, public relations and web design professionals from around the world who share a passion for improving the quality of ...


Researchers Map New Path To Colon Cancer Therapy

Researchers have identified a promising new target in the battle against colorectal cancer -- a biochemical pathway critical to the spread of tumors to new locations in the body. (Read on Source)


Photos: Scenes from the Macworld keynote

Led by VP Phil Schiller, the Jobs-less presentation included a 17-inch MacBook Pro and DRM-free songs in iTunes.