1 Password iPhone app

I have been using one password on my MacBook for some time now and I love it. At times I wonder how I lived without it. As I’m browsing the web I can tell one password to save my login data for that page. I can also set up an identity and give it all the info about me which I can then use to auto fill forms. I can launch the app on my macbook and click to sites and it will auto log me in. In order for the passwords to be auto filled I just login to the app when I launch it. This helps because when other people use my laptop it doesnt auto log them into my web mail.

I just came across the 1 Password iPhone app that does pretty much what the desktop client does but for the iPhone. You can even sync your saved passwords from your computer to your phone. If you’re like me and hate typing in your password everytime you visit a site on your phone I really recommend getting it from the app store. The best part is that it is free right now, so what’s to lose?

Wordpress App for the iPhone

Things have pretty quiet lately. I haven’t been doing a whole lot of development outside of work, but I think I may look for a few freelance gigs. If you know anyone needing a custom php web app shoot me an email.

Now on to the real reason for this post. I was browsing the app store when I stumbled upon the Wordpress app for the iPhone. It was a breeze to set up and even easier to post. Once logging in it shows you your last 30 posts. From there you can edit old posts or create new posts. The app is free and works great which makes it perfect for blogging on the go.

The 30 Day Challenge

WHAT IS THE THIRTY DAY CHALLENGE?

In a nutshell… The Thirty Day Challenge is about making your first $10 online. For a full 30 days we are going to be showing you exactly how to start your own Internet business and generate your first income online without spending a dime.

That’s right, this is going to cost zip, diddly, nothing, nada, ziltch. The entire training program is free, and you won’t have to spend a thing to get your business started and begin making money. No credit card required.

WHEN DOES IT START?

The 2008 challenge will commence on August 1st, but pre-season will start on the 1st of June. Sign up now by entering your first name and email address in the boxes above to receive updates and access to all the challenge training.

Sign up now

Drupal: View all nodes created by a user

I found myself needing to automatically get back all the albums created by a specific user of a site I am working on. Originally I thought that this was going to be a bit more of a challenge. The hardest part ended up being that I found several ways of doing it and each of them were different. I ended up getting the result that I wanted but, not as fast as I wanted it. So maybe this will help someone else trying to accomplish a similar task.

For the process I used you will need the CCK module and the Views module. Then simply follow the steps below to view a list of nodes created by the user that is logged in.

  1. Create your content type using the CCK
  2. Go to the views admin and create a new view
  3. Check the ‘provide page’ check box
  4. Specify a url path for the view (in my case I used album/user)
  5. In the fields section set the fields that you want to show up (this is only useful in list view really)
  6. Set the arguments (this is the most important step, it lets you get nodes by a user)
    ->User: UID is Author - Default: Return page not found
  7. Expand the Argument Handling Code and paste this in it
    if (!args[0]) {
      global $user;
      $args[0] = $user->uid;
    }
     
  8. Set the filters
    ->Node:Type - is one of - (the node type you created)
    ->Node: Published = Yes
  9. Save the view

Now when you navigate to the URL that you supplied in your URL field for the view you should see any nodes of the type you chose. The custom argument handling we added will set the user id to the current logged user if one isn’t specified.

This view was helpful because I was able to use the Node Reference module for the CCK to add a node reference to the albums in my Songs node. Now I had a drop down list of the users albums so that they can relate the new song to an album, but only one of their albums.

Drupal: Pathauto bulk update on specific user roles

Recently I was faced with the problem of needing to run a bulk update in the path auto module for Drupal. Seemed easy enough, but there was one slight problem. Two of my paths had the same alias but different destinations. Users flagged as fans needed one set of destination => alias pairs and artists needed the same alias but with a different destination. The code is fairly simple, but I wanted to share it because it may help someone else. The one query may come in handy for others checking if a user has a specific role they created in their Drupal installation.

<?php
function event_pathauto_bulkupdate() {
  // get the users we need to loop through
  $query = "SELECT uid, name, src, dst FROM {users} LEFT JOIN {url_alias} ON CONCAT(’events’, uid) = src WHERE uid > 0 AND src IS NULL";
  $result = db_query($query);
 
  // set some vars to store stuff in
  $count = 0;
  $placeholders = array();
  $users = array();
 
  // loop through all of the users and get their roles
  // if they have the role of artist then add their user object to our array
  while ($row = mysql_fetch_object($result)) {
    $data = db_query("SELECT r.name as name FROM {role} r, {users_roles} ur, {users} u WHERE r.rid = ur.rid AND u.uid = ur.uid and ur.uid = %d", $row->uid);
    $role = db_result($data);
   
    if ($role == ‘artist’) {
      $users[] = $row;
    }
  }
 
  // loop through our artists and bulkupdate them
  foreach ($users as $user) {
    $placeholders = pathauto_get_placeholders(‘user’, $user);
    $src = ‘event/user/’. $user->uid;
    if ($alias = pathauto_create_alias(‘event’, ‘bulkupdate’, $placeholders, $src, $user->uid)) {
      $count++;
    }
  }
 
  drupal_set_message(format_plural($count,
    "Bulk generation of user events completed, one alias generated.",
    "Bulk generation of user events completed, @count aliases generated."));
}
 

File include based on URL

While working on a project I found myself needing to dynamically include a snippet based on the URL. Doing this would allow me to keep a majority of my PHP code outside of my template, thus allowing me to easily redesign the layout when I needed to. Below was the result:

<?php
  $query_string = substr($_SERVER[‘QUERY_STRING’], 2);
  $match = preg_match(‘!fans/(.+?)/shows!’, $query_string, $value);
 
  $doc_root = $_SERVER[‘DOCUMENT_ROOT’].‘/’;
  $theme_path = ‘path/to/theme/’;
  $filename = ’snippet-’.str_replace(‘/’, ‘-’, $value[0]).‘.tpl.php’;
 
  $file = $doc_root.$base_path.$theme_path.$filename;
 
  if (file_exists($file)) {
    include($filename);
  } else {
    print $content;
  }
 

Cut the cord…

I think I can! Shutdown Day 2008 is coming up soon. May 3, 2008 is Shutdown Day this year, which means go outside. Log out of World of Warcraft, stop tea bagging random people in Halo, and stop camping that doorway in COD 4 and head outside for some real life fun. If you don’t have friends then this will be a great time for you to get out, meet new people and make some.

As for me, this will give me a great chance to rip up the ugly bushes in my backyard and plant some new ones. Maybe even mow my own lawn instead of paying the neighbors kid to do it. My job locks me in to using the computer on a daily basis, but now on this one day I am going to do the unthinkable and venture outside… I better buy some sunscreen, SPF 90.

Help spread the word about Shutdown Day 2008 by adding the badge to your own Wordpress blog. You can get the plugin from blog.projectx4

Back to Wordpress

I decided to switch things up and go back to Wordpress. I just want a blog, no community… I have enough friends. Ok, I don’t have any. But really, Wordpress is just easier for me. Drupal is cool, but it does so much more than i need. So back to the basics. It will take me a bit, but I will be posting some code snippets and how-to items here in the near future.




Bad Behavior has blocked 62 access attempts in the last 7 days.