February 25th, 2010 §
I am used to installing these on CentOS. I did it so many times, I just wrote a script to do it. Simple!
However with Mac OSX and MacPorts, I was having trouble.
I installed MacPorts and then ran through the installers for Apache2, PHP5, and MySQL5 (including the MySQL server)
Set up my http conf file with virtual hosts and this is where everything stopped. I could not get a page to load, and if I did get one to load it would not connect to MySQL.
The problem was my mysql socket. So I made this change:
/opt/local/var/run/mysql5/mysqld.sock
Then, sessions wouldn’t work, so I had to do two things:
- Set the permissions of /private/tmp to 777
- Change the php.ini setting for session.save_path to “/private/tmp”
Once these were done, I was able to load a page and connect to MySQL.
Sphere: Related Content
January 23rd, 2010 §
Sometimes you want to make a link to a specific category only on Wordpress. There are a couple ways you can do this:
1) Create a link to the category page
To do this, you can get the category slug and create a url like this: http://my-url.com/category-slug, where category-slug is your category.
2) Use the wordpress built-in category.php template page. You can get a copy here.
3) You can also do this with a wordpress template page, where you hardcode the category into the page: (Side note: this is a copy/paste/edit of the “Archives” Template page found in the wordpress default Kubrik theme)
-
<div id="content">
-
<div id="entry_content">
-
<div>>
-
<h2><a title="Permanent Link to <?php the_title_attribute(); ?>" rel="bookmark" href="<?php the_permalink() ?>"></a></h2>
-
0', '§ <span class="commentcount">1</span>', '§ <span class="commentcount">%</span>'); ?>
-
<div class="entry"></div>
-
</div>
-
<!– close post_class –>
-
<div class="navigation"></div>
-
<div class="entry">
-
<span class="error"><img src="<?php bloginfo('template_directory'); ?>/images/mal.png" alt="error duck" /></span>
-
-
Hmmm, seems like what you were looking for isn't here. You might want to give it another try - the server might have hiccuped - or maybe you even spelled something wrong (though it's more likely <strong>I</strong> did).</div>
-
</div>
-
<!– close entry_content –></div>
-
Sphere: Related Content
December 31st, 2009 §
Everything serializes, right? Not all the time, more information soon.
Basically, what I was trying to do was to serialize an object into SESSION and pull it later on. Here’s what I did for a test:
-
class test
-
{
-
//some generic code here
-
}
-
-
if (isset($_GET['id'])) {
-
var_dump($_SESSION);
-
var_dump(unserialize($_SESSION['test']));
-
} else {
-
unset($_SESSION['test']);
-
$test = new test();
-
$_SESSION['test'] = $test;
-
header('Location: test.php?id=1');
-
exit();
-
}
All this is is a quick hack that lets me both instantiate the class, set it to session, and look at another page to see if it is still set. When I run this code, the class was being output just fine, meaning that it serialized just fine. However, when I tried to serialize one of my classes (MyClass) in the same code, what I got after serializing was:
This is less than useful.
I found on the php site, after quite a bit of frustrated searching, this post on the PHP.net site, that “N;” means basically “can’t serialize that”.
It turns out that my class had a call to __sleep() in it that was stubbed out and never actually implemented. I removed this stubbed out method, which when I serialized my class gave me exactly what I was looking for. I was able to get to any next script and access my object appropriately.
Sphere: Related Content
December 22nd, 2009 §
I pushed a new version of Twindicate.com live two days ago. That night I was up till 3:45am trying to figure out why OAuth was not working at all. All I could tell was that I was getting a “401 Unauthorized” response from Twitter. I was completely torn apart by this, because I have put hundreds of hours into Twindicate. I honestly thought that Twitter had shut me off without telling me (sorry Twitter).
I tried regenerating my consumer keys, I output lines of debug code at every single step along the oauth code path, I stayed up late two night in a row. I almost cried, I was really choking it back there for a little while. I searched google with no quality results helping me figure out what the issue was.
After 2 days and 4 seperate support requests with Twitter were completely ignored or immediate closed, I went back to the code. I was actually talking with my friend Jason and saw the “body” of the response was encoded. I pulled it out of the response, output it to the page and found the error: “Failed to validate oauth signature and token”. My first response was, “great, tell me something I didn’t know”.
So, I went back to Google and searched for this error. One of the first results was, “Failed to validate oauth signature and token” on Twitter Oauth – Check Your Clock! My first thought, “Ah crap!”.
I checked my clock, it was about 11 hours off. So I fixed it, using the instructions in the Setting the time of your system article.
I am glad that the solution was simple, frustrated that Twitter was not helpful with their support, and sad that my application I spent so much time on is so dependent on something this silly.
Sphere: Related Content
September 30th, 2009 §
So, I have this friend… This is the way many people start their stories when they are really talking about themselves, but this time it is not the case. This story is about a friend of mine, we will call him John.
John runs a website which is a store front and information source for a niche market that didn’t realize they were a niche until John’s website. It is a cool idea for sure. John is not a developer. He runs the company and handles all of the marketing and content that goes on.
When John wanted some new features on his site he came to me and we talked. I informed him that as his site was in .net I was not able to do any programming but I could definitely be a consultant on whatever project he was getting done for his company. John then went out and asked for programmers that new .net and who could handle a project of the size he wanted.
I referred my friend Jason Rowland, who accepted John’s RFP (Request For Proposal) and came back to him with a fully fleshed out proposal. Jason’s proposal came in higher than John expected and the timeline was longer than the other proposal that came in.
Sam sent in the other proposal. His proposal was a more manageable number, something closer to what John was hoping the cost would be for this feature and as I mentioned before, he said he could get it done on a shorter timeline.
Well, you know as well as I do that I would not be writing this story down and sharing it if something didn’t go wrong.
John went with Sam, which made sense at the time because he was cheaper and the feature would be done sooner. After the delivery date that Sam had come and gone, and after the money Sam had asked for did the same, John was worried. I had been talking to John throughout this project, even consulting the developer on one of the features and how to handle it so that it was optimal for SEO, and it didn’t get the site de-listed. I noticed that the developer was a little lost, he was trying things that were misinformed and seemed out of place for a developer of the caliber that was needed for this project.
In the middle of all this, someone noticed that the website was hacked into and there were prescription drug links all over in the source of the pages and told John. John asked Jason to look into it, because Sam was so bogged down with the other project. Again, Jason sent him a proposal of what would be needed. On top of that, Jason noticed a huge security leak in the site that would allow future issues if they didn’t cause the original issue itself. Jason told me about what was going on, because he knew I was friends with John and had been consulting with him along the way. I immediately sent John an email showing him the security issue and how his current developer was the cause of it.
John got Jason on the phone, asked him to figure out how much it would cost to fix all the problems and put Jason in touch with Sam. Sam admitted to Jason that he “left a security vulnerability issue on the site because he figured he’d ‘clean it up on the next go-round’”. John was PISSED, and understandably so. He hired Jason to fix the issues on the site.
As of last night, the repairs have cost John $1000 and things are only partially fixed.
What is the lesson here?
When you ask for proposals and you receive them, please do not look at the number at the bottom. Look at the proposal itself, judge the developer on the amount of time and effort he puts into the proposal. This is a good indication of how dedicated he is to his profession and providing a quality product for you.
When Jason did his proposal, he came in considerably higher than Sam. Up front, this is scary to anyone asking for proposals because they KNOW how much money they will HAVE to shell out and there is no guarantee that the product will work or be finished on time.
John has spent more on the project than Sam proposed and more than what Jason originally proposed. Jason will fix the problems, but no one can work for free so it is going to take some money to fix the glitch (READ: to fix Sam’s crappy job).
This is a tale as old as time, because this happens with any contract work. People will consistently worry about the bottom line and not pay attention to the warning signs. Please learn from John so that you do not make this mistake yourself.
The last time I talked to John his comments to me were:
You and Jason are my go-to developers from now on
Thank God you recommended Jason to us
I just wanna say that you and Jason are good at what you do because you convey trust and that you know what the hell you are doing.
Sphere: Related Content