Feed items

Cake as a webservice, views and magic

I went out today and ended up in a Barnes And Nobel. I wandered through the store and after thinking about reading boring books I went to the section that fascinates me -- the computer section. I glanced through the books they offered and landed on one in particular. That book is RESTful Web Services - Web services for the real world By Leonard Richardson, Sam Ruby. There was one section that I skimmed where the author talked about how every web page was in fact a web service. No matter what. If you don't provide an API people will build one or scrape your data. If you obfuscate your data someone will reverse engineer it and scrape it. If it is published, it's useful, and it's online, it is a webservice. If it's a webservice, why not just open it up?

"That's hard" -- Anyone who has ever tried to write a RESTful service from scratch

Cryptography and the auth component

I wrote this origionally as a bakery article but I am just proud enough of it that I would like to have it under a domain that I own, so here it is

I'm going to start this by doing an abbreviated, without explanation, 3 liner to anyone who doesn't want to read all of this. It is irresponsible for anyone who runs a website that has users/logins to not encrypt your user's password. Step 1: Identify a cryptographically strong function (SHA1/MD5 or even RIPEMD-160) and hash something, anything! Your name, your address, parents middle names followed by their birthdays – whatever you want, but write it down. That is going to be our 'salt'. Now, in your authorization component's password function prepend (put before) the 'salt' to whatever the password is before it goes through your hashing algorithm. Now you have a cryptographically strong password function where as you did not before. Step 3: profit.

CSS Menus

First, I'm so sorry that it took this long for me to add more content to the site. I most definitely broke the 30 days thing, but I learned a lot in school so I'm going to call it a net gain.

Most sites, this one included, imploy "header navigation" to assist their users in finding what they are looking for. Sites like Digg.com, Debuggable.com, and GitHub (not to mention my own!) are all using them. They are a simple and logical way to express navigation but I've found that they are a pain in the ass to code up with css because most people insist on the active class tag being "active" and frankly that's stupid.

Flashers

I have flashed a lot of people. Let me qualify that, I have used $this->Session->setFlash a lot of times in my time with CakePHP. In all those thousands of flashes I can break them into just 4 categories: auth, good, bad, and notices

The categories are fairly simple to understand their purposes so I am not really going to go into that but each one in my mind should have a different presentation and because of that I put a little trick into my app_controllers to allow me to simplify the process of defining the flash type. I make 3 functions in my app_controllers, infoFlash, goodFlash and badFlash which all just call the session component through it's setFlash method

Set flash is a part of the session component and is defined as

Revised model links

In yesterday's post I discussed creating a global app_model (usgin late static binding) function to create a url and with that rolling around in my head I realized that I myself hadn't taken it far enough. I present to you my revised addition to model (and app_model when 5.3 comes out,) the Model::link function.

Static URL's

One of the neat features of PHP 5.3 (the lowest accepted version of PHP in the 2.0 release of CakePHP) is called late static binding. Late static binding is one of those ideas that is a little hard to grasp but if you play enough with singletons you will inevitably run into a good use for it.

First I will briefly explain what static binding is. Static binding (a.k.a. "early binding") is when during compilation the location of the jump in code (ASM JMP) can be determined with ease and because of this, the compiler simply can give it a location in memory to run. Late static binding allows that resolution to be done when the interpretor hits the line of code during execution. The best example that requires this style is when you need to do inheritance backwards. Sometimes it's useful to write a method in a base class that pulls data from the class that is abstracted from it. Late static binding allows this to happen with the "static" keyword.

Welcome

Hello my name is Andrew Allen, freelancer and student in the state of Colorado. This is my little contribution to the CakePHP community. I've long been sucking the intelligence of men much smarter than I, and I've decided to share what little tidbits of knowledge that I can with anyone who happens to grace my pages.

Much in the same fashion of Felix Geisendörfer I feel that I too (along with my new semester starting next monday) will start blogging again. I'm going to throw out whatever Cake tidbits that I can to see if any of it become useful to anyone. All of this will culminate in the release of a behavior that provide you the ability to treat remote xml feeds as you would regular models.