Software Engineering in WordPress, PHP, and Backend Development

Category: Notes (Page 42 of 49)

Notes on programming-related problems that I’ve encountered while working on various projects.

Filtering Custom Controller Actions and Responses in Rails

I’ve been finishing up an application that has a number of custom controller actions. All except one action – the approved action – require user authorization before retrieving any information from the database.

Specifically, I wanted to authentication the administrator for all actions except the approved action for both JSON and XML responses (but not HTML responses).

Here’s how to do it in Rails 3:

Continue reading

Reroute Chrome’s alert() Dialog to the Console

I spend the majority of my time working in Chrome. Whenever I’m working with a lot of JavaScript, I tend to print information to the console for review.

The thing is, typing alert() is much faster than typing console.log() but alert() is exceptionally more annoying. For those of you that want to save a few keystrokes, copy this simple script into a file and include it before any other JavaScript on your site:

Continue reading

Dynamically Creating Anchor Attributes

I was recently tasked with setting up a payment form that would span across two pages. The second form was dependent on information from the first so I needed to pass some data via the query string in order to update the second form.

After completing the first page of the form, the user would click an anchor and then be directed to the second form. Continue reading

« Older posts Newer posts »

© 2024 Tom McFarlin

Theme by Anders NorenUp ↑