Little Calendar Icon in CSS3

Nothing amazing by any stretch… but I built this using CSS3 in about 30 mins. It uses Blueprint CSS mainly for the width control… but you can take that out…


.calendar-sheet {
font-family: Arial, sans-serif;
font-size:1.2em;
}

.calendar-top {
-webkit-border-top-left-radius: 8px;
-webkit-border-top-right-radius: 8px;
-moz-border-radius-topleft: 8px;
-moz-border-radius-topright: 8px;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
background-color: #8B0E0E;
color: #fff;
height:30px;
line-height:30px;
font-size:1em;
text-align:center;
font-family:inherit;
background: #f44949; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2Y0NDk0OSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjU2JSIgc3RvcC1jb2xvcj0iIzhmMDIyMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM2ZDAwMTkiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top,  #f44949 0%, #8f0222 56%, #6d0019 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f44949), color-stop(56%,#8f0222), color-stop(100%,#6d0019)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #f44949 0%,#8f0222 56%,#6d0019 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #f44949 0%,#8f0222 56%,#6d0019 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #f44949 0%,#8f0222 56%,#6d0019 100%); /* IE10+ */
background: linear-gradient(top,  #f44949 0%,#8f0222 56%,#6d0019 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f44949', endColorstr='#6d0019',GradientType=0 ); /* IE6-8 */

}

.calendar-body {
text-align:center;
-webkit-border-bottom-right-radius: 8px;
-webkit-border-bottom-left-radius: 8px;
-moz-border-radius-bottomright: 8px;
-moz-border-radius-bottomleft: 8px;
border-bottom-right-radius: 8px;
border-bottom-left-radius: 8px;
border-left: 1px #f7f7f7 solid;
border-right: 1px #f7f7f7 solid;
border-bottom: 1px #f7f7f7 solid;
font-size: 1.6em;
font-family:inherit;

-moz-box-shadow: -10px 0px 5px #888;
-webkit-box-shadow: -10px 0px 5px #888;
box-shadow: -10px 0px 5px #888;
}

combined with this HTML


<div id="container">
<div>
<div>
<span>April</span>
</div>
<div>
26th
</div>
</div>
</div>

gives you

Pure CSS Baby

Big thanks to the CSS Gradient Generator and Border Radius for saving my typing

Jquery Text box default value

.find(‘.closure-notes input’)
.val(closureMsg)
.focus(function(){

if(! $(this).data(‘hasChanged’) ) {
$(this).val(”);
}
})
.keyup(function(){
$(this).data(‘hasChanged’, true);
})
.blur(function(){
if(! $(this).data(‘hasChanged’)) {
$(this).val(‘Closed’);
}
})

Install OAuth for PHP with PECL

Bit of a ball ache to get this installed… still not sure mine is right. But here’s what I did anyway.

mount -o remount,exec /tmp
pecl install oauth
mount -o remount /tmp

You might need to set up autoconf and autoheader. Do the following
yum install autoconf

after installing, find where it went.
which autoconf
export PHP_AUTOCONF=/usr/bin/autoconf
export PHP_AUTOHEADER=/usr/bin/autoheader

echo “extension=oauth.so” > /etc/php.d/oauth.ini

 

 

Parse email addresses from text file to a csv in 4 lines

$matches = array();
$log = file_get_contents('your-text-file');
$match = preg_match_all("/[a-z0-9!_{|}~-]+(?:\.[a-z0-9?^_{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/", $log, $matches, PREG_PATTERN_ORDER);
file_put_contents('out.csv', implode(PHP_EOL, array_unique($matches[0])));

Developer Interview Questions

I had to interview a couple of developers yesteday for the first time in my career.  Having had plently of interviews myself I thought i’d share with my handful of readers what I asked the candidates.

Our company is looking for a PHP / Frontend developer if you’re interested and can answer the majority of the questions on here, leave your name and address :)

Server side

  1. What version of PHP / MySQL are you most familiar with?

 

  1. What frameworks have you worked on and for how long?
    1. Did you write your own at any point?
    2. Template engines used
    3. WordPress experience
  1. i.      Themes / Plugins?
  2. OOP/Patterns:
    1. i.      Consuming which formats
    2. i.      What approach did you take? SOAP / REST etc.
    3. i.      Nulls.
    4. What’s your CL editor of choice?
    1. Zend Framework experience?
  1. What’s your setup?
    1. Dev environment / clients.
    2. Server set up
    3. Browser
    4. OS
    5. General – happier with a GUI or hardcore CL? Working alone or in a team?
  2. What’s the largest database you’ve worked with? #records.
    1. Performance issues and how they were handled.
    2. Slow queries / tweaking the DB – how would he go about solving these.
  3. What’s the highest volume of traffic any of the projects you’ve worked on has received?
    1. 1 million unique per month – benchmark.
  4. What you’re approach to caching.
    1. How would you serve dynamic content in a high trafficked environment? e.g. School Closures feeds / Now playing info
    2. Ever used Memcached?
    1. Give a couple of examples of the last time he used a design pattern and what for.
    2. Favourite / Most over used pattern?
  1. Dirty hacks!
    1. Give an example of when you’ve thrown something together you’re not proud of and what could you have done better?
  2. Web Services
    1. Give a couple examples of when you’ve worked with web services or API’s
    1. Are you happy working with XML and JSON?
    2. JSONP – what is it?
    3. Have you ever written any API’s?
  1. SQL Skills
    1. Happy writing SQL by hand?
    2. Use a GUI? PhpMyAdmin?
    3. Difference between a PK and a unique?
  1. Sys admin skills
    1. Happy copying / navigating files around on the command line?
    2. Ever deleted anything you shouldn’t have?
    3. Tailing logs? Do you know how?
  1. Version control
    1. Preferred client?
    2. Happy with command line access or prefer a GUI
  2. Regular expressions
    1. Love em or Hate em?

Client Side

  1. HTML skills
    1. Are you working with HTML 4 or 5
  1. i.      If HTML 5, give examples of the things you’ve done.
  2. i.      What other libraries have you used?
    1. YUI / jQuery / Ext / Prototype / Scriptaculous / Moo
  3. i.      Who are Douglas Crockford and John Resig?
  4. i.      Ever used sprites?
    1. Do you code by hand?
  1. Javascript
    1. How would you rate your core (without a framework JS) skills.
    2. What’s your preferred JS library?
    1. Are you happy writing OO JavaScript code?
  1. CSS / Design
    1. Happy to write CSS by hand?
    1. Photoshop / Design experience?
    2. CSS frameworks

 

General

  1. Name your favourite tech sites / blogs you regularly read.
  2. Development goals for this year
    1. Learn HTML 5, Cross Domain AJAX – Intelligent apps.
  3. Any side projects on the go?
  4. Have you ever built any intelligent applications?
    1. Recommendations / Classifiers etc?
  5. Basic aims/techniques of SEO?
  6. Cloud sites?
    1. Ever built any?
  7. Mobile development experience
    1. Ever written any iPhone or Android Apps?
  8. Facebook apps?
  9. Magento Experience?
  10. Facebook / Twitter / MySpace?

2010 in review

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads Minty-Fresh™.

Crunchy numbers

Featured image

A helper monkey made this abstract painting, inspired by your stats.

A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 1,300 times in 2010. That’s about 3 full 747s.

In 2010, there were 19 new posts, not bad for the first year! There was 1 picture uploaded, taking a total of 21kb.

The busiest day of the year was June 17th with 36 views. The most popular post that day was Almost Perfect Rackspace Cloud .htaccess for PHP.

Where did they come from?

The top referring sites in 2010 were stumbleupon.com, news.zf-info.de, twitter.com, stackoverflow.com, and ajaxray.com.

Some visitors came searching, mostly for jquery page turner, page turner jquery, rackspace htaccess, zend multidb, and zend_route.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

Almost Perfect Rackspace Cloud .htaccess for PHP March 2010
3 comments

2

Zend Multi Db September 2010

3

jQuery Page Turner February 2010

4

Zend_Route via Zend_Config_Ini March 2010

5

Dynamically append script tags with parameters to bust cache February 2010

Zend_Db_Table_Row and Zend_Cache

Ever had the message that the Row you’ve retrived from Zend_Cache is not connected? Yet performing a var_dump on the row object shows it’s fully populated. The problem lies whe nthe row is unserialised from Zend_Cache. You must override the __wakeup() function in your row class and then set the table class.

THis is a breeze if you have an interim class extending Zend_Db_Table_Row whcih all your model row classes extend. But you could end up repeating yourself a lot if you’ve not.

Here’s the code:

<?php
class App_Db_AbstractRow extends Zend_Db_Table_Row
{
	public function __wakeup(){
		// tbl comes back as a string
		$tbl = $this->getTableClass();
		
		// dynamically instantiate an instance of the table
		$this->setTable( new $tbl);
	}
}

Zend Fw assumes unserialised data objects should not have access to live database data as stated in the documentation. Credit also Gustavo he also has a simlar solution.

Zend Multi Db

OK So i’ve been writing an app that make heavy use of Zend_Db, across multiple databases using the MultiDb plugin.
Here’s a rough guide of how to set it up.

Now 1st rule I have in any MVC project is to always extend Zend_Db_Table with some form of Abstract class which you then further extend. This gives you a space to provide common functionality across all of your models. So I’ve created 2 extra classes inside the library/App/Db folder and called them App_Db_AbstractTable and App_Db_AbstractRow respoectively. This way I can override any of the initiation logic from Zend for all model classes and provide common methods to all my models. Without these classes this code would need to be duplicated across all my models.

I created two separate connection strings in my config, which looks like this:

; database connection 1
resources.multidb.name1.adapter = PDO_MYSQL
resources.multidb.name1.dbname = 12312423_mydb
resources.multidb.name1.username = 12312423_user
resources.multidb.name1.password = "password"
resources.multidb.name1.host = "mysql50-xx.wc2.dfw1.stabletransit.com"
resources.multidb.name1.default = true

resources.multidb.name2.adapter = PDO_MYSQL
resources.multidb.name2.dbname = 444444_db2
resources.multidb.name2.username = 444444_dbuser2
resources.multidb.name2.password = "7213d8TShkd478"
resources.multidb.name2.host = "mysql50-xx.wc2.dfw1.stabletransit.com" - different cloud machine

In my bootstrap for the entire application I initialise the MultiDb plugin to store these adapters in the registry thus:

	protected function _initDbAdaptersToRegistry()
	{
		$this-&amp;gt;bootstrap('multidb');
		$resource = $this-&amp;gt;getPluginResource('multidb');
		$resource-&amp;gt;init();
				
		$Adapter1 = $resource-&amp;gt;getDb('name1');
		$Adapter2 = $resource-&amp;gt;getDb('name2');		
		Zend_Registry::set('Adapter1RegKey', $Adapter1);
		Zend_Registry::set('Adapter2RegKey',$Adapter2);
		
	}

In that method you can also stuff in some profiller initialisation code too if you use it etc etc.

Then in the App_Db_Abstract I setup the database adapter.

class Model_User extends App_Db_AbstractTable
{
	protected $_rowClass = 'User';
	
	protected $_name = 'table_name';
	
	protected $_schema = '';
	
	protected $_adapter = 'Adapter1RegKey';

I override the _setupDatabaseAdapter() method in the App_Db_AbstractTable to set the adapter as an object direct from the registry.

	protected function _setupDatabaseAdapter() 
	{
		$this-&amp;gt;_db = Zend_Registry::get($this-&amp;gt;_adapter);
	}

There’s MultiDb set up and working. Hope that helps.

iTunes Categories as a PHP array

$cats = array('Arts'=> array(
			'Design',
           'Fashion & Beauty',
           'Food',
           'Literature',
           'Performing Arts',
           'Visual Arts'
	  ),
		  
     'Business'=>array(
          'Business News',
          'Careers',
          'Investing',
          'Management & Marketing',
          'Shopping'
	 ),
     'Comedy'=>array(),
	 
     'Education' => array(
          'Education Technology',
          'Higher Education',
          'K-12',
          'Language Courses',
          'Training'
	),
    'Games & Hobbies' => array(
          'Automotive',
          'Aviation',
          'Hobbies',
          'Other Games',
          'Video Games'
	),
    'Government & Organizations' => array(
           'Local',
           'National',
           'Non-Profit',
           'Regional'
	),
    'Health' => array(
          'Alternative Health',
          'Fitness & Nutrition',
          'Self-Help',
          'Sexuality'
	),
	'Kids & Family'=>array(),
    'Music'=>array(),
    'News & Politics'=>array(),
    'Religion & Spirituality'=>array(
          'Buddhism',
          'Christianity',
          'Hinduism',
		  'Islam',
          'Judaism',
          'Other',
          'Spirituality'
	 ),
     'Science & Medicine'=>array(
          'Medicine',
          'Natural Sciences',
          'Social Sciences'
	 ),
     'Society & Culture'=>array(
          'History',
          'Personal Journals',
          'Philosophy',
          'Places & Travel'
	),
    'Sports & Recreation'=>array(
          'Amateur',
          'College & High School',
          'Outdoor',
          'Professional',
     ),
	 'Technology'=>array(
	      'Gadgets',
          'Tech News',
          'Podcasting',
          'Software How-To'
	),
    'TV & Film'=>array()
);

Javascript video resources

Adobe TV Ajax Experience

17 Hours from the Masters