Posted on

New Gig

Got a new job.
Its only been a few days but I’m loving it already.
The people are awesome.
The project is cool.

Cant really talk about what I am working on.
Legalize is hard to understand, and its better to be safe then sorry.

Posted on

iPad

I got an iPad.
Its getting me a lot of attention.
On the 761 heading south from the valley,
I saw a helicopter stop traffic and make lifts.
And there was a bunch of hoodlums on the
bus who saw me and started talking jive.
But it was it cool, we had a laugh, they call me iPad. 🙂

And today I had a meeting and my iPad was the center of attention for a minute.

Posted on

Craigslist Scraper

I got this craigslist scraper and it collected about 380 emails from the LA computer gigs area.
So I sent them an email blast today. Sent out this blog. Its looking good, I got 20 impressions so far, when I usually don’t have any.

Posted on

SIRIdms

Working on a website, up on my subdomain http://siridms.winwinhost.com.
Doing lots of UI, css, its really cool, having good luck with CSS this time.
It’s a tableless design, pretty sophisticated.
With popups and other “moving parts.”

Posted on

Zend_View View Scripts

View Scripts

Once your controller has assigned variables and called render(), Zend_View then includes the requested view script and executes it “inside” the scope of the Zend_View instance. Therefore, in your view scripts, references to $this actually point to the Zend_View instance itself.

Variables assigned to the view from the controller are referred to as instance properties. For example, if the controller were to assign a variable ‘something’, you would refer to it as $this->something in the view script. (This allows you to keep track of which values were assigned to the script, and which are internal to the script itself.)

By way of reminder, here is the example view script from the Zend_View introduction.

  1. <?php if ($this->books): ?>
  2. <!– A table of some books. –>
  3. <table>
  4. <tr>
  5. <th>Author</th>
  6. <th>Title</th>
  7. </tr>
  8. <?php foreach ($this->books as $key => $val): ?>
  9. <tr>
  10. <td><?php echo $this->escape($val[‘author’]) ?></td>
  11. <td><?php echo $this->escape($val[‘title’]) ?></td>
  12. </tr>
  13. <?php endforeach; ?>
  14. </table>
  15. <?php else: ?>
  16. <p>There are no books to display.</p>
  17. <?php endif;?>

Escaping Output

One of the most important tasks to perform in a view script is to make sure that output is escaped properly; among other things, this helps to avoid cross-site scripting attacks. Unless you are using a function, method, or helper that does escaping on its own, you should always escape variables when you output them.

Zend_View comes with a method called escape() that does such escaping for you.

  1. // bad view-script practice:
  2. echo $this->variable;
  3. // good view-script practice:
  4. echo $this->escape($this->variable);

By default, the escape() method uses the PHP htmlspecialchars() function for escaping. However, depending on your environment, you may wish for escaping to occur in a different way. Use the setEscape() method at the controller level to tell Zend_View what escaping callback to use.

  1. // create a Zend_View instance
  2. $view = new Zend_View();
  3. // tell it to use htmlentities as the escaping callback
  4. $view->setEscape(‘htmlentities’);
  5. // or tell it to use a static class method as the callback
  6. $view->setEscape(array(‘SomeClass’, ‘methodName’));
  7. // or even an instance method
  8. $obj = new SomeClass();
  9. $view->setEscape(array($obj, ‘methodName’));
  10. // and then render your view
  11. echo $view->render(…);

The callback function or method should take the value to be escaped as its first parameter, and all other parameters should be optional.

Using Alternate Template Systems

Although PHP is itself a powerful template system, many developers feel it is too powerful or complex for their template designers and will want to use an alternate template engine. Zend_View provides two mechanisms for doing so, the first through view scripts, the second by implementing Zend_View_Interface.

Template Systems Using View Scripts

A view script may be used to instantiate and manipulate a separate template object, such as a PHPLIB-style template. The view script for that kind of activity might look something like this:

  1. include_once ‘template.inc’;
  2. $tpl = new Template();
  3. if ($this->books) {
  4. $tpl->setFile(array(
  5. “booklist” => “booklist.tpl”,
  6. “eachbook” => “eachbook.tpl”,
  7. ));
  8. foreach ($this->books as $key => $val) {
  9. $tpl->set_var(‘author’, $this->escape($val[‘author’]);
  10. $tpl->set_var(‘title’, $this->escape($val[‘title’]);
  11. $tpl->parse(“books”, “eachbook”, true);
  12. }
  13. $tpl->pparse(“output”, “booklist”);
  14. } else {
  15. $tpl->setFile(“nobooks”, “nobooks.tpl”)
  16. $tpl->pparse(“output”, “nobooks”);
  17. }

These would be the related template files:

  1. <!– booklist.tpl –>
  2. <table>
  3. <tr>
  4. <th>Author</th>
  5. <th>Title</th>
  6. </tr>
  7. {books}
  8. </table>
  9. <!– eachbook.tpl –>
  10. <tr>
  11. <td>{author}</td>
  12. <td>{title}</td>
  13. </tr>
  14. <!– nobooks.tpl –>
  15. <p>There are no books to display.</p>

Template Systems Using Zend_View_Interface

Some may find it easier to simply provide a Zend_View-compatible template engine. Zend_View_Interface defines the minimum interface needed for compatability:

  1. /**
  2. * Return the actual template engine object
  3. */
  4. public function getEngine();
  5. /**
  6. * Set the path to view scripts/templates
  7. */
  8. public function setScriptPath($path);
  9. /**
  10. * Set a base path to all view resources
  11. */
  12. public function setBasePath($path, $prefix = ‘Zend_View’);
  13. /**
  14. * Add an additional base path to view resources
  15. */
  16. public function addBasePath($path, $prefix = ‘Zend_View’);
  17. /**
  18. * Retrieve the current script paths
  19. */
  20. public function getScriptPaths();
  21. /**
  22. * Overloading methods for assigning template variables as object
  23. * properties
  24. */
  25. public function __set($key, $value);
  26. public function __isset($key);
  27. public function __unset($key);
  28. /**
  29. * Manual assignment of template variables, or ability to assign
  30. * multiple variables en masse.
  31. */
  32. public function assign($spec, $value = null);
  33. /**
  34. * Unset all assigned template variables
  35. */
  36. public function clearVars();
  37. /**
  38. * Render the template named $name
  39. */
  40. public function render($name);

Using this interface, it becomes relatively easy to wrap a third-party template engine as a Zend_View-compatible class. As an example, the following is one potential wrapper for Smarty:

  1. class Zend_View_Smarty implements Zend_View_Interface
  2. {
  3. /**
  4. * Smarty object
  5. * @var Smarty
  6. */
  7. protected $_smarty;
  8. /**
  9. * Constructor
  10. *
  11. * @param string $tmplPath
  12. * @param array $extraParams
  13. * @return void
  14. */
  15. public function __construct($tmplPath = null, $extraParams = array())
  16. {
  17. $this->_smarty = new Smarty;
  18. if (null !== $tmplPath) {
  19. $this->setScriptPath($tmplPath);
  20. }
  21. foreach ($extraParams as $key => $value) {
  22. $this->_smarty->$key = $value;
  23. }
  24. }
  25. /**
  26. * Return the template engine object
  27. *
  28. * @return Smarty
  29. */
  30. public function getEngine()
  31. {
  32. return $this->_smarty;
  33. }
  34. /**
  35. * Set the path to the templates
  36. *
  37. * @param string $path The directory to set as the path.
  38. * @return void
  39. */
  40. public function setScriptPath($path)
  41. {
  42. if (is_readable($path)) {
  43. $this->_smarty->template_dir = $path;
  44. return;
  45. }
  46. throw new Exception(‘Invalid path provided’);
  47. }
  48. /**
  49. * Retrieve the current template directory
  50. *
  51. * @return string
  52. */
  53. public function getScriptPaths()
  54. {
  55. return array($this->_smarty->template_dir);
  56. }
  57. /**
  58. * Alias for setScriptPath
  59. *
  60. * @param string $path
  61. * @param string $prefix Unused
  62. * @return void
  63. */
  64. public function setBasePath($path, $prefix = ‘Zend_View’)
  65. {
  66. return $this->setScriptPath($path);
  67. }
  68. /**
  69. * Alias for setScriptPath
  70. *
  71. * @param string $path
  72. * @param string $prefix Unused
  73. * @return void
  74. */
  75. public function addBasePath($path, $prefix = ‘Zend_View’)
  76. {
  77. return $this->setScriptPath($path);
  78. }
  79. /**
  80. * Assign a variable to the template
  81. *
  82. * @param string $key The variable name.
  83. * @param mixed $val The variable value.
  84. * @return void
  85. */
  86. public function __set($key, $val)
  87. {
  88. $this->_smarty->assign($key, $val);
  89. }
  90. /**
  91. * Allows testing with empty() and isset() to work
  92. *
  93. * @param string $key
  94. * @return boolean
  95. */
  96. public function __isset($key)
  97. {
  98. return (null !== $this->_smarty->get_template_vars($key));
  99. }
  100. /**
  101. * Allows unset() on object properties to work
  102. *
  103. * @param string $key
  104. * @return void
  105. */
  106. public function __unset($key)
  107. {
  108. $this->_smarty->clear_assign($key);
  109. }
  110. /**
  111. * Assign variables to the template
  112. *
  113. * Allows setting a specific key to the specified value, OR passing
  114. * an array of key => value pairs to set en masse.
  115. *
  116. * @see __set()
  117. * @param string|array $spec The assignment strategy to use (key or
  118. * array of key => value pairs)
  119. * @param mixed $value (Optional) If assigning a named variable,
  120. * use this as the value.
  121. * @return void
  122. */
  123. public function assign($spec, $value = null)
  124. {
  125. if (is_array($spec)) {
  126. $this->_smarty->assign($spec);
  127. return;
  128. }
  129. $this->_smarty->assign($spec, $value);
  130. }
  131. /**
  132. * Clear all assigned variables
  133. *
  134. * Clears all variables assigned to Zend_View either via
  135. * {@link assign()} or property overloading
  136. * ({@link __get()}/{@link __set()}).
  137. *
  138. * @return void
  139. */
  140. public function clearVars()
  141. {
  142. $this->_smarty->clear_all_assign();
  143. }
  144. /**
  145. * Processes a template and returns the output.
  146. *
  147. * @param string $name The template to process.
  148. * @return string The output.
  149. */
  150. public function render($name)
  151. {
  152. return $this->_smarty->fetch($name);
  153. }
  154. }

In this example, you would instantiate the Zend_View_Smarty class instead of Zend_View, and then use it in roughly the same fashion as Zend_View:

  1. //Example 1. In initView() of initializer.
  2. $view = new Zend_View_Smarty(‘/path/to/templates’);
  3. $viewRenderer =
  4. Zend_Controller_Action_HelperBroker::getStaticHelper(‘ViewRenderer’);
  5. $viewRenderer->setView($view)
  6. ->setViewBasePathSpec($view->_smarty->template_dir)
  7. ->setViewScriptPathSpec(‘:controller/:action.:suffix’)
  8. ->setViewScriptPathNoControllerSpec(‘:action.:suffix’)
  9. ->setViewSuffix(‘tpl’);
  10. //Example 2. Usage in action controller remains the same…
  11. class FooController extends Zend_Controller_Action
  12. {
  13. public function barAction()
  14. {
  15. $this->view->book   = ‘Zend PHP 5 Certification Study Guide’;
  16. $this->view->author = ‘Davey Shafik and Ben Ramsey’
  17. }
  18. }
  19. //Example 3. Initializing view in action controller
  20. class FooController extends Zend_Controller_Action
  21. {
  22. public function init()
  23. {
  24. $this->view   = new Zend_View_Smarty(‘/path/to/templates’);
  25. $viewRenderer = $this->_helper->getHelper(‘viewRenderer’);
  26. $viewRenderer->setView($this->view)
  27. ->setViewBasePathSpec($view->_smarty->template_dir)
  28. ->setViewScriptPathSpec(‘:controller/:action.:suffix’)
  29. ->setViewScriptPathNoControllerSpec(‘:action.:suffix’)
  30. ->setViewSuffix(‘tpl’);
  31. }
Posted on

How to configure a secondary DNS server

This step-by-step article describes how to configure a secondary DNS server.

Identify the Secondary Name Server

On the primary DNS server, identify an additional name server. To do this, follow these steps:

  1. Click Start, point to Administrative Tools, and then click DNS.
  2. In the console tree, expand Host name (where Host name is the host name of the DNS server).
  3. In the console tree, expand Forward Lookup Zones.
  4. Right-click the zone that you want (for example, example.com), and then click Properties.
  5. Click the Name Servers tab, and then click Add.
  6. In the Server fully qualified domain name (FQDN) box, type the host name of the server that you want to add.

    For example, type namesvr2.example.com.

  7. In the IP address box, type the IP address of the name server that you want to add (for example, 192.168.0.22), and then click Add.
  8. Click OK, and then click OK.
  9. In the console tree, click Reverse Lookup Zones, right-click the zone that you want, and then click Properties.
  10. Click the Name Servers tab, and then click Add.
  11. In the Server name box, type the host name of the server that you want to add.

    For example, namesvr2.example.com.

  12. In the IP address box, type the IP address of the name server that you want to add (for example, 192.168.0.22), and then click Add.
  13. Click OK two times.

Install DNS on the Secondary Name Server

To install the DNS service, follow these steps:

  1. Log on to the computer as an administrator.
  2. Click Start, point to Control Panel, and then click Add or Remove Programs.
  3. Click Add\Remove Windows Components.
  4. In the Components list, click Networking Services (do not click to select or click to clear the check box), and then click Details.
  5. Click to select the Domain Name System (DNS) check box, and then click OK.
  6. On the Windows Components page, click Next.
  7. Insert the Windows 2003 Server CD when you are prompted, and then click OK.
  8. On the Completing the Windows Components Wizard page, click Finish.
  9. Click Close.

    DNS is now installed. To start the DNS snap-in, click Start, point to Administrative Tools, and then click DNS.

Configure the Forward Lookup Zone

To configure the forward lookup zone on the secondary name server, follow these steps:

  1. Log on to the secondary name server as an administrator.
  2. Click Start, point to Administrative Tools, and then click DNS.
  3. In the console tree, under DNS, click Host name (where Host name is the host name of the DNS server).
  4. In the console tree, click Forward Lookup Zones.
  5. Right-click Forward Lookup Zones, and then click New Zone.
  6. When the New Zone Wizard starts, click Next to continue.
  7. Click Secondary Zone, and then click Next.
  8. In the Name box, type the name of the zone (for example, example.com), and then click Next.
  9. On the Master DNS Servers page, type the IP address of the primary name server for this zone, click Add, click Next, and then click Finish.

Configure the Reverse Lookup Zone

To configure the reverse lookup zone on the secondary name server, follow these steps:

  1. Click Start, point to Administrative Tools, and then click DNS.
  2. In the console tree, click Host name (where Host name is the host name of the DNS server).
  3. In the console tree, click Reverse Lookup Zones.
  4. Right-click Reverse Lookup Zones, and then click New Zone.
  5. When the New Zone Wizard starts, click Next to continue.
  6. Click Secondary zone, and then click Next.
  7. In the Network ID box, type the network ID (for example, type 192.168.0), and then click Next.

    Note The network ID is that portion of the TCP/IP address that pertains to the network.

    For additional information about TCP/IP networks, click the article number below to view the article in the Microsoft Knowledge Base:

    164015 (http://support.microsoft.com/kb/164015/EN-US/ ) Understanding TCP/IP Addressing and Subnetting Basics
  8. On the Zone File page, click Next, and then click Finish.

Troubleshoot

  • The Zone Is Not Loaded by the DNS Server

    When you select a zone on the secondary name server, you may recieve the following error message in the right pane of the DNS window:

    Zone not loaded by DNS Server

    The DNS server encountered an error while attempting to load the zone.
    The transfer of zone data from the master server failed.

    This issue may occur if zone transfers are disabled. To resolve this issue, follow these steps:

    1. Log on to the primary name server computer as an administrator.
    2. Click Start, point to Administrative Tools, and then click DNS.
    3. In the console tree, click Host name (where Host name is the host name of the DNS server).
    4. In the console tree, click Forward Lookup Zones.
    5. Under Forward Lookup Zones, right-click the zone that you want (for example, example.com), and then click Properties.
    6. Click the Zone Transfers tab.
    7. Click to select the Allow zone transfers check box, and then click one of the following options:
      • To any server
      • Only to servers listed on the Name Servers tab
      • Only to the following servers.

        Note If you click Only to the following servers, type the IP address of the secondary name server in the IP address box, and then click Add.

    8. Click Apply, and then click OK.
    9. Quit the DNS snap-in.
  • How to Troubleshoot DNS

    To troubleshoot and obtain information about the DNS configuration, use the Nslookup.exe utility.

    For additional information about using Nslookup, click the article number below to view the article in the Microsoft Knowledge Base:

    200525 (http://support.microsoft.com/kb/200525/EN-US/ ) Using Nslookup.exe
Posted on

PrimaOro.com & hdmispot.com

I made some changes to primaoro.com today.

Put in a checkout button in the product detail page, and restacked the google checkout button with the original button on the cart page.

Hope it will make purchasing easier.

I also have a meeting with masis, so I have to finish hdmispot.com changes today.
I just moved the search bar, added the visa mastercard logo on the bottom, and setup the x-cart static pages.

I am burned out. I don’t feel good about the interviews, Disney stood me up, and I haven’t heard anything good from any of the other recruiters either. Burn.

Posted on

Interviews: Sodahead and Disney

How exciting, I got a 1pm meeting today with Sodahead. I blew my chance to hook up with VC funded start up three years ago. I just didn’t know enough about MVC, and ORM, and Agile Development. The same problem occurred at Disney and Varient.

Varient didn’t like me because I had never seen ->assign(‘name’,$value) statements before. And I totally flunked one of their questions, “Create a left hand menu with 3 random links selected from a database”. I was so amped the night before, and crashing so hard that day, I went into my own world of .. use rnd() and use a loop to get 3 unique id numbers. when the answer was “select * from links order by rand limit 3”.

Sodahead didn’t like me because I didn’t know about Agile Development, or Scrum, and I had no clue what ORM, or object relational mapping is. What was I supposed to say? I mean, we didn’t have main stream frameworks at Bill McCaffrey’s setup, and their servers were getting 2 billion page view’s a month. Bill taught me that the best most efficient way to extend PHP is with C. He also taught me, screw oracle, write your own middleware, in C.

I hope to have changed this precedent, and today I will find out, as I walk into a Django backend and YUI frontend shop, Sodahead.com
And then do a phone screening with Disney.

Manifesto for Agile Software Development

We are uncovering better ways of developing
software by doing it and helping others do it.
Through this work we have come to value:

Individuals and interactions over processes and tools
Working software over comprehensive documentation
Customer collaboration over contract negotiation
Responding to change over following a plan

That is, while there is value in the items on
the right, we value the items on the left more.


Posted on

Problems with People Aggregator

I am having some installation issues on my domain with this people aggregator software. Totally not happy. It says the software doesn’t work on a non linux box, well they weren’t kidding.

Posted on

Let me make your iphone app.

I’ve got a special deal going on for the person to give me my first iphone app project. I’ll work at the starving student price discount, which means insane productivity fueled by caffeine and sugar, at dirt cheap prices. Don’t be shy, get on this deal!