I’ve been working on a WordPress project lately that is housed on an Amazon EC2 server, using Bitnami. Overall, it’s a pretty awesome setup, giving me total free reign to setup the server how I need. Everything worked great on the QA server, but for some reason, after we moved the code to the production server, users started complaining about the inability to post any media (images, video, etc.) to their posts. They were getting a permissions error in WordPress trying to create the upload directory.
My initial thought was to use chmod to give all users write permissions to the folder in question. This couldn’t be done, however, as it opens up an obvious security hole.
So Next I checked out the QA site, and realized that the user and group owning the htdocs directory were daemon and bitnami, respectively. This was not the case on the prod server. So it became obvious that WordPress was hitting this directory as the daemon user, and did not have ownership rights to it. So I gave it to them:
chown -R daemon:bitnami /opt/bitnami/apps/wordpress/htdocs
And viola! The issue was resolved. This little jaunt down the rabbit hole, however, got me thinking about permissions as a whole when it comes to WordPress. I did some further reading and came across this great article regarding security on the wordpress platform. I highly suggest you give it a look.
If you only care about the meat and potatoes, as most developers often do, these two snippets are what you want. If you have shell access to your server, you can change file and folder permissions recursively with these bad boys, and set them to the correct permissions the WordPress team suggests.
For Folders:
find /path/to/your/wordpress/install/ -type d -exec chmod 755 {} \;
For Files:
find /path/to/your/wordpress/install/ -type f -exec chmod 644 {} \;
Good luck!
Well, we are officially making the transition to sublime as a team. I for one am happy, as this will make it much easier for us to share and version control many of the short cut benefits of this powerful coding tool. Its also an application that is very singular in how customizable it is, through preference files in JSON format.
One of said preference files is the tmTheme file, which is used for creating a color scheme for the codebase in sublime. Now, there are quite a number of good theme files out there, however none seem to play well with JSPs, at least not well enough for myself. I for one cannot have my JSTL tags the same color as my html. Blasphemy!
So, I proceeded to edit the theme to my liking, starting with a theme called “Tomorrow Night.” This started off well, however I came upon a stumbling block: the language file for JSP just wasn’t granular enough to color what I wanted. I could make JSP tags purple, but had no control over their child attributes or operators. This would not do.
Enter the tmLanguage file:
<!-- Targeting all of the JSP tags/attributes separately; This should let us color them however we want --> <dict> <!-- Start by targeting all alphanumeric tags with colons in them --> <key>begin</key> <string>(</?)([a-zA-Z0-9]++(:)[a-zA-Z0-9]+)</string> <key>beginCaptures</key> <dict> <key>1</key> <dict> <key>name</key> <string>punctuation.section.embedded.dsp</string> </dict> <key>2</key> <dict> <key>name</key> <string>meta.tag.block.dsp</string> </dict> </dict> <!-- then target the closers purple --> <key>end</key> <string>(>)</string> <key>endCaptures</key> <dict> <key>1</key> <dict> <key>name</key> <string>punctuation.section.embedded.dsp</string> </dict> <key>2</key> <dict> <key>name</key> <string>meta.tag.block.dsp</string> </dict> </dict> <key>patterns</key> <array> <!-- target the substrings separately --> <dict> <key>match</key> <string>([""'])(?:(?=(\\?))\2.)*?\1</string> <key>name</key> <string>string</string> </dict> <!-- target the equals separately --> <dict> <key>match</key> <string>([=])</string> <key>name</key> <string>constant.other.color</string> </dict> </array> </dict>
This guy let me add more granularity to the language targeting, such as looking for tags with the colon character in them, surrounded by anything alphanumeric. This is a very common structure in JSTL.
Once I set this up, I was able to target specific pieces in my JSP tags in order to color them. The specific string names that I setup are in red below, pointing to the specific part of the code that is targeted to color:

Anywho, I’ve placed the code on Github for your use. You will need to clone two separate repos, as I have one for both the theme and language file:
Day After Tomorrow Night Theme
Updated Sublime Jave bundle
Any questions, just let me know.
Enjoy!
I’ve been getting in the habit of moving preferences, and git repos to dropbox lately. It lets me edit them in one place, and have access to them on multiple machines immediately, which is a huge win for me.
I was talking to a buddy tonight about moving my git config file there, and he had suggesting symlinking with Dropbox. Now, I just need to symlink the same file at home, and I’m working with the same settings on both machines!
[ ~ ] $ cd ~/Dropbox/ [ ~/Dropbox ] $ mkdir dotFiles [ ~/Dropbox ] $ mv ~/.gitconfig ~/Dropbox/dotFiles/ [ ~/Dropbox ] $ ln -s ~/Dropbox/dotFiles/.gitconfig ~/.gitconfig
Wow, this on really made my head hurt for a bit.
So I’ve been building a WordPress site hat is using a custom post type of “help.” As you can probably guess, this is for a help section. The data on these help pages is fairly extensive, so I set my post type up to be hierarchical. No problem so far.
Next, I setup a page template for these custom posts (single-help.php). This is where it got a bit tricky; I had three levels of data, all which needed a functional editor so users could input html, and each level needed its own layout, pulling in only its sub posts. So essentially, my page template ended up looking like so (albeit a bit more convoluted).
<?php // setup your arguments: $args = array( // We want to call all posts the custom post type 'help' 'post_type' => 'help', 'posts_per_page' => -1, 'post_status' => 'publish', 'order' => 'ASC', // Next, we want to see if the current post is a parent of any help posts 'post_parent' => $post->ID ); // We then pass these to a wordpress query, and setup our loop $loop = new WP_Query( $args ); ?> <?php if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post(); ?> <!-- This post has children, so we'll list them out --> <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> <?php endwhile; ?> <?php else : ?> <!-- This post has no children --> <?php endif; ?>
So basically, this code allowed my single-help file to handle all three levels of the help page hierarchy, loading in each when necessary.
Lemme know your thoughts. I’d love to clean this up a bit more.
Well, I took a quick look at my Page Speed results today, and it looks like Google is angry at me for my inability to leverage browser caching. Essentially, I’m reaching out to the server for every image on my site, even if the user has loaded it already. Seems like a ton of extra unnecessary work eh?
Well, htaccess to the rescue! I added the following to my .htaccess file, which sped up my site considerably (and also upped my Page Speed score). I opted to set my headers to a long time for both images, css, and js for now, since I don’t really update the look of my site that often. When I do decide to, I’ll most likely rename my js and css files, and removed the old ones.
# Setting Cache Control Headers # 480 weeks <filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> Header set Cache-Control "max-age=290304000, public" </filesMatch> # 2 DAYS <filesMatch ".(xml|txt)$"> Header set Cache-Control "max-age=172800, public, must-revalidate" </filesMatch> # 2 HOURS <filesMatch ".(html|htm)$"> Header set Cache-Control "max-age=7200, must-revalidate" </filesMatch>
Anyone out there have any suggestions on ways to set cache control? This was my first attempt at it, and I’d love some feedback!
Ran into this today with a WP site I was working on. I didn’t want the default version of jquery that’s included now with wordpress, so I found this handy dandy script so that I could load the latest from google. I just added it to the bottom of my functions.php file:
//forcing jquery to load the version we want
function my_scripts_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
wp_enqueue_script( 'jquery' );
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
This was my Christmas gift to Lauren this year! An Industrial Chic, Steampunk esque Chess set. I found the board on Etsy, and built the pieces out of nuts and bolts from the hardware store. I got one side rusted using Patina Blue solution, which I found from this sweet tutorial.
If you want to make your own, or you want a set, drop me a line!
So I finally got Outlook for Mac at work this week, and I really like it so far. One thing I immediately noticed was missing, however, was the ability to setup signatures to not show on any replies and forwards. This is pretty important to me, since I’m frequently getting myself into pretty deep email chains, and I don’t want my email and phone number on all 75 emails in them.
This was definitely a problem that needed a fix. A quick google search, and I found a solution: Application Shortcuts. This is a pretty awesome tool on the mac, that seems glaringly absent from windows. What it does is basically give you the ability to set keyboard shortcuts for any application, and manage them all via system preferences:
Well, here is my next foray into the world of industrial chic design. As with my ladder shelf, this coffee table is made completely from reused items, right down to the screws. The top is made from hardwood flooring straight from a basketball court, which I found at Construction Junction. Also from CJ are the 2×4′s and legs, made from case iron pipe I cut down, and leveled off with adjustable pipe fittings as feet. The drawers are from an old filing cabinet I had in storage. It turned out to be a fun project, and it feels good to recycle old goods into some cool furniture.
Check out the pics below to see the steps I went through, and feel free to comment and let know what you think!
So I built some shelving out of a ladder last week, and figured I’d post some pictures, as well as a simplified tutorial. The process was pretty simple, and only took a few hours to build. It also cost me a whopping $2.50 for the whole thing, since I found two old ladders on Craigslist for 5 bucks.
The ladders were from Lousville Ladder Company, circa 1988. That officially makes this shelving only a few years younger than me
After cleaning the ladder, I took off the top rung, as well as the metal attachment on the side holding the ladder together. This was done by chiseling off the heads of the rivets. I just did this with a chisel and hammer, and made sure to wear thick gloves, because I like to miss and hit my hand from time to time.
Next, I measured the width of the shelves, and cut some old weather worn boards into the correct shelving length. I made sure to use some thicker boards, to the middles wouldn’t bow.
Then, I put my lader into my inset upside down, and laid in the boards, getting them all level. This took a good bit of shimmying on each end of the ladder, as the rungs on each side were not the same height to begin with. Once I got them level, I marked the spots on the wood, and gave each a dot of wood glue, just to keep them from sliding. Not too much though, as I would like to have the freedom to move this shelving later.
That’s just about it. I decorated the shelves up with some plants and the like, and ended up with some pretty cool shelving. Finally, as a bonus, I took the top rung that I had removed, and made it into a key hanger with some random hooks I had in my workroom. Now I just need to use the metal fasteners from the middle of the ladder for something, and I’ll have used every part of the ladder!