Adding Cachable Javascript and CSS links to your Wordpress Theme
Here is a great technique for adding a timestamp to your the javascript and css for your theme using enqueue_script and enqueue_style. The benefit is you can set a far future expires header and maximize the caching benefit without having to worry about cache invalidation. This technique should be familiar to any Rails devs as it's baked in.
The magic is that the one of the optional parameters of the enqueue_* functions is a version. We can use php's filemtime function to get the last modified time of the file as a timestamp and use it for the version. Wordpress appends the version to the end of the url like "http://yoursite.com/wp-content/themes/your-theme/style.css?ver=1265429348". Now you don't have to worry about serving stale data since every time you edit the file the url will be updated.
Here is some example code:
function theme_assets() { stylesheet_url = get_bloginfo('stylesheet_url'); stylesheet_path = TEMPLATEPATH."/style.css"; stylesheet_mtime = filemtime(stylesheet_path); wp_enqueue_style("my_theme", stylesheet_url, false, stylesheet_mtime, "screen"); javascript_url = get_bloginfo('stylesheet_directory')."/my_theme.js"; javascript_path = TEMPLATEPATH."/my_theme.js"; javascript_mtime = filemtime(javascript_path); wp_enqueue_script('my_theme', javascript_url, false, javascript_mtime, true); } add_action('template_redirect', theme_assets);
The Definition of Missions
I recently was asked the definition of missions. Here is my attempt to sum up it's essence into an apt statement.
Missions is the duty of the church, in which we as the redeemed in gratitude and love get the privileged to announce the riches of our redemption to those who are lost as we once were. That the Holy Spirit chooses to work in, arresting the heart of men and granting them the gift of repentance unto life.
Sometimes programming problems are best solved AFK
This afternoon I ran into a problem. I was working on adding in some new form fields on an edit screen. The fields were for an associated model. I was using fields_for in the view and accepts_nested_attributes_for in the model. Everything looked great, but my specs were still failing. The form just wasn't updating the association.
I desk checked the code. I tried it in script/console. I checked the controller logs. I tried everything I could think of. I struggled for an hour or so before I called in for help. By then end of the day, neither a more experienced developer or myself could figure out why it wasn't working. We were ready to blame plugins, rails, or anything else. Looking over the code, everything looked correct.
Calling the @my_model.my_association_attributes= worked, but the controller was never calling it! Can you guess what the culprit was? The model had attr_accessible set!
So is the moral of the story to add the association_attributes on models with attr_accessible? Not exactly, see I didn't solve the problem at my desk. I solved the problem on the way home from church about two and a half hours later. I wasn't even thinking about the problem when it popped in my head.
Sometimes the right course of action is to just step away from the problem for awhile, and let our mind work on it. A week or so ago, I had struggled for a couple hours trying to figure out how to solve a particular problem cleanly. I had about half a dozen ways to solve it, but thinking of actually implementing any of them made me feel dirty. I knew there was a good way to solve this problem.
How did I come up with a solution? I slept. When I woke up, brushed my teeth, and fired up textmate the next morning in my head was a elegant (and obvious) solution to the problem at hand. Sometimes our minds just need a break.
Next time you get frustrated, step away for a bit. Let your mind relax and refresh. AFK isn't as bad as it sounds, and sometimes it's medicinal.
You Failed. Autotest with a voice.
While listening to a talk from Ruby Conf 08, I heard Joe Martinez mention the say command in OS X. I figured I'd pop open my .autotest file and wire it up so it'd give me some motivation for when my specs go red.
Here is what I added:
Autotest.add_hook :red do |autotest| `say -v "Good News" "You're doing it wrong"` end
Home Title Not Displaying Correctly with All in One SEO Pack
A client contacted me that the custom home title had stopped working with their install of the All in One SEO Pack. The site was using a home.php file to provide a custom home template. The problem was that in the reading settings "A static page" was selected even though no front page or posts page was selected.

Once updated to "Your latest posts" it worked correctly. Hopefully this will save you some time if you run across the same issue.
Welcome President Obama
I would like to say welcome Mr. President Obama. No, you were not my choice. However, I believe in the constitution. I believe in democracy. I believe in America.
Moreover, I believe in God.
Example of my JavaScript Skills – Blackjax
I was asked to provide some JavaScript for a job interview. Awhile ago I had started to build a JavaScript version of blackjack. I got the idea from while reading "The Object-Oriented Thought Process." In the sixth chapter Matt Weisfeld used Blackjack as a case study of Designing with Objects.
The Value of Clarity in Preaching
An idea that is hopefully accurate to the text, fairly succinct, somewhat memorable, or perhaps just plain clear. These are the sermons that gradually transform lives.
Often times during revivals, bible conferences, camp meetings, and the like we are exposed to preaching that is of the highest of caliber. Just today I had the privilege of hearing 6 messages that were exceptional. While these messages were amazing, as I read Peter's words tonight on preaching I am reminded of the immense value of "just plain clear" preaching.
"Campmeeting Preaching" may stir our souls. It may lead us to deeper understanding of God's word. It is plain preaching that provides the foundation. Preaching the meat and potatoes of the word of God is fundamental and needed. Peter's admonition to preach accurate and simple is one we preachers should heed.
Follow Him
And he saith unto them, Follow me, and I will make you fishers of men. And they straightway left their nets, and followed him.
-
The Call for Following Christ
Follow me.
Christ commands us to follow him. -
The Consequence of Following Christ
The disciples were transformed. No longer professional anglers, but now evangelists.
-
The Completeness of Following Christ
The disciples didn't take there nets with them as a backup.
What Manner of Love
Behold, what manner of love the Father hath bestowed upon us, that we should be called the sons of God: therefore the world knoweth us not, because it knew him not.
-
The Sovereignty of Love
It was love
bestowed. -
The Substance of Love
How great is this adopting love!
-
The Subjects of Love
It is bestowed on us
-
The Sustainer of Love
Forrest Gump hd It is the love of a Father. It will not fail.