Posts with tag: How To

28 Feb

Installing xhprof on XAMPP for OSX Lion

Directions adapted from Ben Buckman. Download xhprof. cd path/to/xhprof/…/extension # If you don’t have autoconf… I didn’t. sudo chmod o+w /usr/local/bin #(brew needs to write a symlink there) brew install autoconf sudo /Applications/XAMPP/xamppfiles/bin/phpize Make sure you have a CLI C compiler. I installed one via XCode. sudo MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ LDFLAGS=’-O3

[...read the post]
4 Dec 2012

Designing a Highly Reusable HTML Component

The UF College of Education uses a header/footer template designed to be applied to any page, and we use this across several applications such as WordPress, Moodle, Elgg, and Drupal. Changes can be propagated quickly to all sites, and adding the template to new PHP apps is trivial. If you need to create an HTML component that can be

[...read the post]
18 Jul 2011

Helping Netbeans/PhpStorm with Autocomplete/Code-hinting

Where Netbeans can’t guess the type/existence of a local variable, you can tell it in a multiline comment: /* @var $varName TypeName */ After this comment (and as long as TypeName is defined in your project/project’s include path), when you start to type $varName, Netbeans will offer to autocomplete it, and will offer TypeName method/property suggestions.

[...read the post]
22 Apr 2011

Bash: Resolve symlinks in your working directory

Say you have created a symlink from your home dir to another location: $ ln -s /Applications/XAMPP/xamppfiles/htdocs ~/htdocs Now you can easily change to the XAMPP htdocs: cd ~/htdocs and then get back home: cd .. But how do you get to xamppfiles? Update: Thanks to sapphirepaw, the solution is simple: cd -P htdocs/.. or

[...read the post]
2 Feb 2011

Filtering WordPress Navigation Menus

WordPress 3 introduced native navigation menus, usually created via the wp_nav_menu theme function and the built-in Custom Menu widget.  If you have a menu with a deep hierarchy, you may want to display only the active branch and the submenu directly below the active item (given class “current-menu-item” by WordPress). You can see this menu

[...read the post]
21 Nov 2010

Customizing a Zend Navigation Menu

Zend Navigation has a menu helper class that can output a basic nested UL menu. You can set id/class attributes on the A elements, and it adds an “active” classname to A elements in the active branch, but customizing the markup beyond that gets complicated.

[...read the post]
14 Nov 2010

Using jQuery Before It’s Loaded

It’s better to include scripts like jQuery at the end of the BODY, but this makes its methods inaccessible earlier in the page (e.g. inside a WordPress post). What you can do is use a script like the one below to queue DOMReady functions before jQuery loads. (function (w) { if (w.$) // jQuery already

[...read the post]
14 Nov 2010

Tiny E-mail Munging Script

I’ve seen a lot of these that are bloated/less effective/inaccessible, so I might as well put this out there. It’s simple enough to modify if you’re comfortable with Javascript. Markup: <a href=”mailto:john{@}example{.}org”>john{@}example{.}org</a> (function(){ var a, i = 0, o = this.onload; onload = function(){ o && o(); // run the old window.onload if existed while

[...read the post]
1 Nov 2010

A Zend Framework App in a Single File

Most PHP micro-frameworks I’ve reviewed have some major cons: incomplete namespacing of functions/classes/global vars; doing too much/little; being under-tested; and the worst: forcing a unique (and usually under-documented) code structure that will make it difficult to “graduate” an app into a more full-featured framework. It also seems silly to rely on “micro-optimized” code if performance

[...read the post]
2 Sep 2010

StackExchange folks, KeyMinor already exists

Why is there a StackExchange proposal in the works for a “Musical Practice and Performance site” when KeyMinor already exists on the SE platform? The proposed site is “for people who play musical instruments. On-topic questions will be about technique, practice, theory, composition, and repertoire.” KeyMinor already serves this purpose, it’s just not known about.

[...read the post]
5 Aug 2010

Research Chain E-mails in 30 Seconds

A friend or family member has just forwarded you a wonderful piece of propaganda: It’s filled with inflammatory bare assertions, stirring anecdotes, and a dare to pass it on to everyone you know! And no sources. 1. Find a phrase in the message that’s a) unlikely to appear in anything else on the web, and

[...read the post]
22 Jul 2010

Chords: The Flaming Lips “All We Have is Now”

[Song on YouTube] All the tabs I could find were crap, so I wrote up a guitar arrangement. The inverted voicings in the choruses made it tough to figure out, but capoing the 2nd fret gets it pretty close. Capo 2nd fret. / = 1/4 note V1) A 3-5-5-4-3-x (2 bars) As logic stands you

[...read the post]
14 Jul 2010

MVC: M != the Database

Great article on the misunderstood scope of the “Model” in the Model-View-Controller architecture. The takehome: Models are commonly thought of as wrappers for database access/stored objects, but application state and business logic need to go in them, too. Otherwise you get bloated controller and/or views that clumsily try to take care of these concerns. Earlier

[...read the post]
5 Jul 2010

Bass for Stereolab’s “Miss Modular”

“Miss Modular” has an amazing bass line. It’s probably looped on record, but they play it live…and usually faster than the recording. I’m fairly sure it’s capoed at the 7th fret—that’s how I’ve typed it up here. Stereolab “Miss Modular” Capo bass @ 7th fret. spaces/numbers/hyphens = 1/16th notes. / = 1/4 notes. Intro) /

[...read the post]
2 May 2010

Uh-Oh: Firefox’s Unique Session Cookie Behavior

By now, Opera’s invention of restoring tabs automatically is available in most browsers, but unlike every other browser, Firefox’s restored tabs retain session cookies for the domains of the saved tabs Firefox restores all session cookies as if the browser were never closed. This is handy in some ways, but dangerous in others: It’s fooling

[...read the post]
16 Apr 2010

Bash script: recursive diff between remote hosts

This script will generate a recursive, unified diff between the same path on two remote servers. You set the CONNECT1 and CONNECT2 variables as necessary to point to your hosts/paths. Of course, the users you connect as must have read access to the files/directories you’re accessing. #!/bin/bash # USAGE: ./sshdiff DIRECTORY # # E.g. ./sshdiff

[...read the post]
3 Apr 2010

Elgg, ElggChat, and Greener HTTP Polling

At my new job, we maintain a site powered by Elgg, the PHP-based social networking platform. I’m enjoying getting to know the system and the development community, but my biggest criticisms are related to plugins. On the basis of “keeping the core light”, almost all functionality is outsourced to plugins, and you’ll need lots of

[...read the post]
22 Feb 2010

Guitar Tuning By Ear

(This is edited from an answer I posted to KeyMinor, a music Q&A site. They need more users!) A lot of recordings end up slightly higher/lower than standardized pitch (I always called this “in the cracks” but don’t google it!), and this is the quickest way I’ve found to tune a guitar to them.  This

[...read the post]
15 Feb 2010

Bash: unbom (to remove UTF-8 BOMs)

Tests for and removes UTF8 BOMs. #!/bin/bash for F in $1 do if [[ -f $F && `head -c 3 $F` == $'\xef\xbb\xbf' ]]; then # file exists and has UTF-8 BOM mv $F $F.bak tail -c +4 $F.bak > $F echo “removed BOM from $F” fi done USAGE: ./unbom *.txt The magic is tail

[...read the post]
28 Jan 2010

SQL Server 2008, Domain Auth, PHP5, Ubuntu Server

May this save you pain.

[...read the post]