All posts by stephen

I am Here

Location! Location! Location! The three words you usually here when looking for real estate. But what about in the cyber world. What does this really mean? We have location services for GPS, and that works great for items like navigation systems, and locating devices. Location services for tracking purposes, like with shipping services and company vehicles. But now we have location services for Tweets, Updates, and Check-ins. What does this really mean or get one?

In previous posts, some of the things I have experienced, I have posted. Some of this has been on the business side, and some has been on the personal side. But the question I usually seem to get often, is why should anyone be a part of Foursquare, or use any type of location services. And that is a fair question. If some method is not useful for a business, then why use it? If some new technology comes out and the person is not that interested, why use it? And that is the question only one person can answer: you. Whether it is for yourself or for your business, it is something that you must decide if this is right for you. Not all technology or services will be a “one size fits all”. Especially in technology, if it is a one size fits all, then it usually will not be able to do what you need it to do.

So let’s first examine the personal aspect of the location based services. What are some of the benefits for a person to use it, besides broadcast/brag to the world where you are? One of the reasons I use it is when I travel. By checking in at different locations on the journey, I can let me friends, family and business associates know where I am. Foursquare has a great tool to post to Twitter and Facebook as well, so you can get all bases covered in one check-in. Another reason I use it is so I can still “play around” with friends and associates who are no longer close. We have contests to see who can check in the most, become mayor of as many places as possible, who goes to the most areas, etc. It is another way to keep those relationships alive. I also use check-ins when I go to new places, especially restaurants, to see if there are any deals, or suggestions, or better yet, cautionary advice to stay away from a place. And most important thing to remember about Foursquare, if I do not want to be found, I do not check in at all. Just because one has the service does not mean one has to use it all the time.

Next, why should a business use it. This all depends on what the business is. Obviously if the business does a lot of secret projects, then they probably do not want to check in all the time. But there are useful ways to use Foursquare. First, a business should register the place, venue, location. Once you are there, make it exciting for people to check-in (and by that, they make it in your door) by offering them something. Even if it is 10% off a drink, or copies, etc. In this economy, even 10 cents could be the difference maker. And on the same token, offer interesting items, or tips, about the place. Movie theatres can offer tips like all movies before 4pm are matinee and cheaper prices, or days when there are not as many people showing up to the theatre. This can drive traffic and revenue on some of the more slower times. And make sure you read what others post about the place. This is invaluable as it is direct feedback about the business and how it is perceived. A really good presentation examines what different companies have done with Foursquare and was presented by David Stutts, 20 Interesting Things: Foursquare. Yes this is 11 months old and technology changes quickly. But this should give a good start on generating ideas on what could be useful.

Thoughts

Today I am going to break from the schedule and post about something different, jobs.

In this country (and I am sure around the world), jobs are hard to come by. What is even more difficult is finding the right kind of job where one is happy and challenged. Not every job is glamorous, and not every job will make you a millionaire. There has to be something out there that will make one happy, challenge them and make it not seem like a job. Too many people are out there working 80 hours a week out of fear of losing the job. Do more, cost less, and be more productive seems the be the sense in businesses today. Salaries are going lower for the regular every day worker, while the hours have gone up. Fear of being out of a job for months can drive that person to work a ton and kill themselves in the job.

Yes, I speak from firsthand experience. Getting downsized, or re-structured, from a business you put your life into really sucks. And when you do get a job after that, sometimes there is a fear that drives the person to work harder (not always more efficient mind you), work longer hours, not cost as much, and more like this. In the past, businesses were more loyal to the worker. Today, they are not. As much as we build strong relationships with the people at the job, when it comes down to the bottom line, everyone is a number, figure against the balance, and can always be expendable. Which is sad.

I think more people would be dedicated, and take ownership of their work if they knew that they were not expendable, and at any downturn in the economy, they would be safe. And I know this does not apply to everyone, but I feel that it would be a lot better. We all want to do something cool with our lives, and have a legacy. Too many times we misplace that legacy as a product of our work, instead of family and service. We put all our effort, time and energy into the job, one that many of us dread going to every morning, and then spend maybe 1 hour a day with family.

Sure, I am writing this from the perspective of a father and husband. And I know many out there are either single or have no intention of having children. And that is fine, there is no problem with that as well. But there are other legacies out there. Service and helping others out. Taking time to help others is huge, and touches more lives than we will ever know. It provides a sense of self worth and confidence. And if nothing else, it helps one maintain perspective.

Yes we all need to pay bills and provide for ourselves or our family. I am not saying go quit your job and live like a hippy. In fact, I am saying just the opposite of that. Find something that makes you happy, and does not suck your soul. Make it so that you can be excited about the day, instead of watching the clock for the end of the shift.

PHP Web Service Example Set Up

In a previous few posts, I posted examples for the NuSOAP server. Now it is time for the intrinsic PHP SOAP web service. This will be a quick post for the server and client, as they are easy to do. The hard part will be the WSDL document. With NuSOAP, it created a WSDL for you, but with PHP SOAP, you must do the WSDL yourself. Be sure to read up on the documentation at PHP.net.

So first off, we need to create a few ideas on what we will return. This will be a simple example with data returned. So for the data set, we will return an array of colors, and an array of named pairs for boys/names and girls/names. Two simple methods to the service, and we need to build the client as well.

So this post will only be the set up of those, and maybe next week I will post the actual server and client code. So for now, here are the data arrays we are going to work with:

$colors = array(
	'blue', 
	'green',
	'black'
	'white',
	'yellow'
	'red',
	'beige'
);

$names = array(
	'boys' => array(
		'stephen',
		'dave',
		'ryan',
		'brian',
		'chris',
		'tom',
	), 
	'girls' => array(
		'elise',
		'sheri',
		'kim',
		'marci',
		'megan',
	)
);

And we will need the WSDL file in place. So the basic layout for this webservice server will act like this:
1. All calls to the colors function will not take any type of parameters, it will be:

$webservice->__soapCall('getColors')

2. Calls to the names function can be one of three options: both, girls, boys:

$webservice->__soapCall('getNames', array('boys'))

3. Both functions will return some type of message header and array of returned data.
4. The data is set up above, and the structure will be the same.

Now knowing this, if we get the WSDL set up and working, then the service will work. So next week, I will show the WSDL, the Server and the Client.

Part 2 including the code

Will you really know what it takes

So I am entering week three of this month and trying to get things completed. So here is the latest in the line of items that will be done this week:

Monday – Will you really know what it takes; Planning ideas and thoughts
Tuesday – PHP Web Service Example; focusing on coding
Wednesday – Facebook, Foursquare, Twitter oh my!; ideas and code segments for people like me, social lepers
Thursday – I am Here; examinations on location services, social integration and strategy
Friday – Funny quotes; fun stuff to finish up the week

For today, it is going to be short, and more of something to think about. Someone asks you to do something. You have this project in which you need to rely on other groups and other people to help complete the project. Will you really know what it takes? Sure, we may really be in tune with what is out there, and we may understand our part in this, but when we start to get more people and other groups involved, it can become a little confusing as to what it will really take. These other groups may not have the time or resources to work on this project right away, so that may introduce more meetings and political suave to convince a different set of executive management to understand your project. Time allowed for the work to be completed may be a question that comes up as well.

What about your own personal time? How much do you have on your plate, and how interesting is your work? Is this new project something you see as wonderful, and a challenge that is good? Or is it more of a mundane routine you are seeing yourself increasingly doing more often? Is your heart in the project, if it is not, how will that affect the effort you put in? When everything is said and done, your name will be associated with this project, in some way shape or form. Is this something you will be proud of, or will it haunt you later in your career?

400 Words to Madness

So ends the week, on Friday the 13th no less. I have less than 400 words to sum up the week:
Monday: work
Tuesday: work
Wednesday: work
Thursday: work
Friday: work

Not really a big change or variety. However some very interesting things happened this week in other news. And relating a story that came to me at work this week. Life is full of randomly boring events happening independently. But put all those items together, and it becomes a really interesting and fun experience. And that is what life should be, fun and entertaining. So while I finish this post off for this week, I am just going to remind everyone that life is worth living and experiencing.

Items to possibly watch this weekend:
The Office episode this week (DVR’d)
Hot Tub Time Machine
Easy A
Harvey (you can never ignore the classics)
The Seventh Seal (one of the best art house movies)
L’Avventura

I also need to get outside and get some sun, clean my motorcycle, etc. But what movies would you watch if you could?

Following the Yellow Brick Road

Location services, another word for allowed electronic stalking. Yet it is something that is getting more traction. Sure it may not seem like a big deal to some, to others it is the lifeblood, and still to others, it is an answer to a question no one asked. So what is so amazing about social media/location services and why should anyone follow this yellow brick road?

Well, first off, lets answer that with some common sense. First off, I do not really care to know if you checked in at your bathroom. I also really do not care if some vending machine is giving you your favorite drink. I think the movie “Easy A” sums it up best:

Mr. Griffith: [to Olive] I don’t know what your generation’s fascination is with documenting your every thought…but I can assure you, they’re not all diamonds. “Roman is having an OK day, and bought a Coke Zero at the gas station. Raise the roof.” Who gives a rat’s ass?

Exactly! Some social media use goes way overboard and way too much information. It is like everyone in a room talking extraordinarily loud saying nonsense and spouting the first thing to come into their mind. Yes it can be funny at times, but it soon becomes annoying. People turn this off, and soon ignore all other information coming from these sources, even if it is important and pertinent. Make it worth the time to read/listen.

Restaurants are already seeing the value of this. Checking in at the place can give you a discount, free appetizer, etc. Movie theatres would be wise to step up with this as well, maybe even distribution companies too. Imagine this: Checking in at a theatre with a mention of which move you are seeing = free popcorn. Heck, my wife would tweet that without hesitation. And what does it really cost the theatre for the popcorn? (Besides, I am convinced that they make all their money on soda anyway, you pay $8 for a large cup that contains mostly ice and maybe a teaspoon of actual soda). Not only would the theatre be getting basically free advertising, so is the movie!

Not sure how to start this up? Try Mashable: HOW TO: Set Up a Foursquare Special. Great information in that article. Make it worthwhile, and make it relevant. Remember Mr. Griffith’s very astute observation.

Who Do You Like

By now, everyone and their dog has heard about Microsoft’s coup to acquire Skype for $8.5B. Based on what you read, Microsoft is going to have either the best X-Box Live experience, or create an Office web suite that will one up the online meeting space. Or the other news making the rounds, Google’s web based music service. Come on, be honest, which one did you really know about? And that is the whole thing. Two amazing things happened this week, and only one got tons of press, coverage and was talked about more. So who do you like?

And that is what it comes down to for you, or your business – who do you like? Are you following and friending people just so you can beat Ashton Kutchner’s records, or are you trying to build relationships? Social connections should be less of a race to get the most people and more of building a cohesive community. This community should be focused on your business goals mixed with ways for the community to be involved in the project or become part of the direction. Social connections are also more mobile, so that should also be a main focus. Gone are the days of the young geeks huddled in the basement, logging on chat boards while playing Dungeons and Dragons. It is no longer the “geeks” who are connected, it is everyone. They are connecting via the phones, pads, and laptops. Just today, as I pulled in fill up my tank with outrageously expensive gas, the station had 10 cars at the other islands. Seven of those people were out filling up the tanks, texting, chatting, checking emails, etc. They all had their phones out and using them, not to make calls, but connecting to their community.

This is the new direction of the connected world. It is not in front of a computer screen, but out and active. Now that Microsoft has purchased Skype, and Google is starting a web based music service, there will be less and less reasons to focus traditional read/write web applications. Interactions will build relationships, and in turn, build who likes you and bring lasting business relationships.

Count the Number of Cakes – Finding complex results with CakePHP

CakePHP offers a good selection of tools to help you retrieve the data. Recently, I came into a situation where I needed to find and paginate results based on a single, distinct column in the table. Distinct data can be tricky, especially if the tools do not allow you to select the distinct based on a column. Distinct will check all columns returned, and coupling in time stamps, 99% of the time all rows will be distinct. So how do you grab the data? Well, first lets examine the sample data that is needed to be extracted first.

The sample data is in a MS SQL Server database. The table contains a record ID, title id, author id, genre, type, last check out date, and edit date. It is possible to have duplicate title, author IDs in the table. We need to extract all DISTINCT title IDs, along with the other information listed where the type is not a paperback, and provide a paginated list. I am sure this would be better architected if needed in the real world. Paginate will only get us so far, as this would only show all records.

class BooksController extends AppController {
    var $paginate = array(
        'order'        => array('Book.id' => 'desc'),
        'fields'    => array('Book.id', 'Book.title_id', 'Book.author_id', 'Book.genre_id', 'Book.type', 'Book.check_date', 'Book.edit_date'),
        'limit'        => 15,
    );
    . . . 
    function index(){
        $this->set('hardback_books', $this->paginate());
    }
}

We need to use more to build a conditional query so the paginate will query against this. We can use CakePHP’s data source to help in this. Now, we could also just write this query out ourselves, but this is helpful to know so when you have to build sub-queries for other items. All data is in MS SQL Server, and we can use normal SQL expressions, but we need to grab DISTINCT data, which goes by rows, not columns, which means we will need to do 2 sub-queries in addition to the main one. So we first need to grab a list of the TOP 1 items. This will be our inner query.

        SELECT TOP 1 * 
        FROM [books] AS [bk_inner] 
        WHERE 
            [bk_inner].[title_id] = [Book].[title_id] 
            AND 
            [bk_inner].[type] <> 'paperback' 

Next, we need to encapsulate that query with an outer one that will select all items which match up to the main query ID.

    SELECT * FROM 
    (
        SELECT TOP 1 * 
        FROM [books] AS [bk_inner] 
        WHERE 
            [bk_inner].[title_id] = [Book].[title_id] 
            AND 
            [bk_inner].[type] <> 'paperback' 
    ) AS [bk_outer] 
    WHERE bk_outer.[title_id] = Book.[title_id] 

So we have the queries, and it needs the main query needs to constrain the results that exists in the sub-queries.

SELECT TOP 15 
    [Book].[id],
    [Book].[title_id], 
    [Book].[author_id], 
    [Book].[genre_id], 
    [Book].[type],
    CONVERT(VARCHAR(20), [Book].[check_date], 20)
    CONVERT(VARCHAR(20), [Book].[edit_date], 20)
FROM [books] AS [Book] 
WHERE EXISTS 
(
    SELECT * FROM 
    (
        SELECT TOP 1 * 
        FROM [books] AS [bk_inner] 
        WHERE 
            [bk_inner].[title_id] = [Book].[title_id] 
            AND 
            [bk_inner].[type] <> 'paperback' 
    ) AS [bk_outer] 
    WHERE bk_outer.[title_id] = Book.[title_id] 
) 
ORDER BY [Book].[id] desc

We have the final full query. Now how do we get that? First, we need to invoke the getDataSource() method.

class Book extends AppModel {
    . . . 
    function getHardbackBooks(){
        $dbo = $this->getDataSource();

Next we need to use the buildStatement() to build each statement. Since CakePHP will build a sub query with this, we have to do this twice: once for the inner query, and once for the outer query. The “table” for subquery2 will actually be subquery1, so we need to add that as a “table” in the array.

$subquery1 = $dbo->buildStatement(
	array(
		'fields' => array('TOP 1 *'),
        'table' => $dbo->fullTableName($this),
        'alias' => 'bk_inner',
        'limit' => null,
        'offset' => null,
        'joins' => array(),
        'conditions' => 'bk_inner.title_id = Book.title_id AND bk_inner.type <> \'paperback\'',
        'order' => null,
        'group' => null
	
	),
	$this
);

$subQuery2 = $dbo->buildStatement(
    array(
        'fields' => array('*'),
        'table' => '(' . $subquery1 . ')',
        'alias' => 'bk_outer',
        'limit' => null,
        'offset' => null,
        'joins' => array(),
        'conditions' => 'bk_outer.[title_id] = Book.[title_id]',
        'order' => null,
        'group' => null
    ),
    $this
);

Now, we need to make sure we add an EXISTS:

$subQuery = ' EXISTS (' . $subQuery2 . ') ';
return $subQuery;

Return the data from the model to the controller. In the controller function we need to add a new condition to the paginate. In the conditions, we do not need to use a paired item value to set it, we can use the straight SQL returned from the model.

class BooksController extends AppController {
    var $paginate = array(
        'order'        => array('Book.id' => 'desc'),
        'fields'    => array('Book.id', 'Book.title_id', 'Book.author_id', 'Book.genre_id', 'Book.type', 'Book.check_date', 'Book.edit_date'),
        'limit'        => 15,
    );
    . . . 
    function index(){
        $data = $this->Book->getHardbackBooks(); 
        // Set to the paginate object conditions
        $this->paginate['conditions'] = array($data);
        $this->set('hardback_books', $this->paginate());
    }
}

And it returns the items based on the paginate parameters, ready to use in the view. It provides a DISTINCT list. And yes, I know I used more than 400 words in this one. It was closer to 500 without the code. Oh well, maybe tomorrow will be shorter.

Two People Get On an Elevator

This week it is going to be a little different for all posts. I am still going to follow the format from the past weeks, but all posts this week will be 400 words or less. Including the code posts I will be doing.

Up for this week:
Monday – Two People Get On an Elevator; Planning ideas and thoughts
Tuesday – Count the Number of Cakes; focusing on coding
Wednesday – Who Do You Like; ideas and code segments for people like me, social lepers
Thursday – Following the Yellow Brick Road; examinations on location services, social integration and strategy
Friday – 400 Words to Madness; fun stuff to finish up the week

Some of the best ideas are planned in 400 words or less. At one company, this was called the elevator pitch. You have that short of a time to sell someone on your idea. Have you planned it through? Do you even know what it will do beyond your own comprehension? These are things to remember when trying to plan for the pitch. Not everyone is able to just quit their job, work on their own project and be able to fund their ideas, equipment to get up and going, and market this thing. Many people need to have some kind of investor(s) backing. So how would you sum up some of the greatest products in less than 400 words.

One semester I had to come up with ideas to do this. We had to take products that already existed, examine what they did, what benefit they provided, and why they were in demand. These products were not necessarily ones that we knew of. And we had to present these benefits to the rest of the class, and had to do it in under 4 minutes. We could not talk fast, and we had to be coherent. Our grades were going to be determined by anonymous feedback from the rest of the class. If the pitched worked, we would get good grades. If not, we would fail.

In the real world, it is much the same. You have about 400 words to sell your idea. You have made the plans, models, diagrams, etc. Now you need to get someone to back this idea. Much like everything else, you must plan for this. Highlight good points, ROI, and ease of use. Practice on other products. In 400 words, describe the product and your vision.