technology

Drupal code formatting for Zend Studio or Eclipse

This post started out about code formatting, but it's grown to include all my Eclipse setup.

History
Originally I built a PHP formatter in Zend Studio, but I had difficulties setting up the free Eclipse PDT with this config. I followed instructions at: http://drupal.org/node/75242, then tweaked some of the configuration. I pulled it into Eclipse (Juno), changed the XML paths and ignored the warnings, then resaved it out again from the wizard to get it in the right format.

Eclipse setup

PHP development IDEs and why you should have one

I've been doing a lot of development in PHP recently. I started programming in C/Codeworks, but it wasn't until I did some work in OpenCV and Visual Studio that I started seeing the value of IDEs. Having a good debugger is essential to resolving bugs in a timely manner. While it's possible to integrate a text editor, profiler and version control system with a debugger, it takes time to setup and maintain this tool chain, time that I'd rather pay someone else to spend.

Linux shutdown command variants

shutdown -r now
resets and restarts the computer

shutdown now
turns some machines off (which is technically called a halt)

shutdown -h now
shutdown and halt/turn machine off

Can't call arguments.slice() in JS

Javascript is a wonderful language, full of twists and turns. I was surprised that I could:


arguments.length

but not


arguments.slice()

It turns out it's because arguments is not a real array, but a function, which you can access like an array, e.g.:


arguments[0]

To do a slice() op on it:


var args = Array.prototype.slice.call(arguments, 1);

Debugging concurrent javascript in Firebug using QUnit

QUnit queues up all the javascript tests, then runs them. This means you get an accurate picture of how long the tests take to run sequentially, but you have to be very careful about multi-threaded execution. When testing DiSCO, I had to keep using QUnit.stop and .start() whenever I had an asynchronous event between tests.

Also, when setting breakpoints in Firebug, be careful to set them inside the test functions as your code will be operating in two different timeframes. Below t0 is the test setup timeframe and t1 the test execution timeframe.


------- |-t0--- |-t1---

Using SVN hooks to run QA tests on Javascript

Read a great primer by Amaxus on Using JSlint with Subversion hooks. There were a few bugs, largely created by missing \ characters in the published source. My working version is published zipped up below.

Multithreaded wget alternative for Linux or Mac OS X

Happened across aget today. The source is available from http://www.enderunix.org/aget/aget-0.4.1.tar.gz.

To compile under Mac OS X (10.6 Snow Leopard), you need to add -D_DARWIN_C_SOURCE to the gcc compile flags in the Makefile.


# EnderUNIX Aget Makefile
# http://www.enderunix.org/aget/

OBJS = main.o Aget.o Misc.o Head.o Signal.o Download.o Resume.o
CFLAGS = -g -W -D_DARWIN_C_SOURCE
LDFLAGS = -pthread
CC = gcc
STRIP = strip

all: $(OBJS)

Windows 7 file sharing with XP/OSX peers

Recently I've been blighted by a minor network glitch that meant I couldn't file share from my Windows 7 laptop. I was convinced it was something to do with Windows Firewall, ESET NOD32 or even the ZyXel router. I downloaded the excellent Wireshark and used it to analyse the packets; lots of outgoing requests but nothing back from my server (miata). I could ping and transfer HTTP packets, but no file sharing.

Wireshark set up

Windows-based PHP profiling with Xdebug and Kcachegrind

The last few weeks of development have driven me to adopt some old technologies from my C days. I've got PHP setup with a debugger (Xdebug and the buggy Komodo IDE) and a profiler (Kcachegrind) under Windows (WAMP Server). Today I optimised one tiny part of the DiSCO codebase:

Kcachegrind screenshot, before

IE CSS transparency bug

As part of my experimentation for Thinkope, I'm often setting opacity on divs and their containers. I've exposed this IE transparency bug which renders correctly in Firefox but cuts a hole out of the top div in Internet Explorer.

Snapshot demonstrating cut-out bug


Alex Stanhope is a Technology consultant to the UK Creative Industries and Venture Catalyst. This is my personal website.
Bristol | Lightenna | ManKind Project | goodkarma
All material copyright (c) 2006-2010 | Website by Lightenna, featuring N.Design's GlossyBlue theme.
Syndicate content