The public menace posed by the Ghost Ship - the San Francisco-area warehouse that recently became the scene of the nation's deadliest structure fire in more than a decade - was not as spectral as its name suggested. Neighbors and others had lodged dozens of complaints about people living in the building and garbage accumulating around it. The lack of subtlety about its illicit use could be measured by the presence of several RVs inside the structure and a Facebook mission statement advertising its "helter skelter spelunker shelters."

A similar kind of malfeasance pervaded the scene of the 2013 Philadelphia building collapse that killed six and injured 13, now on display in a civil trial. Besides the track record of property owner Richard Basciano, whose buildings had been havens for blight and pornography for decades, there were plenty of warnings the cut-rate demolition of one of his vacant buildings would end badly. As witnesses have detailed, sidewalk and roof protections required by city code never appeared, the Salvation Army workers next door correctly feared the worst, and Basciano's right-hand man fulminated to a top city official about the prospects for serious injury "or worse."

Though separated by the breadth of the country and more, the disasters in Philadelphia and Oakland, Calif., are united in having been preventable through basic code enforcement, an all too scarce resource in both cities. Each case features a cast of culprits, but neither could have happened without a degree of local lawlessness.

The man in the middle of the Oakland mess appears to be Derick Almena, who sublet corners of the warehouse to squatters and opened it to underground parties and concerts like the one that drew most of the 36 who perished in this month's fire. A self-described "thriller love child of Manson, Pol Pot and Hitler," Almena makes for a fine villain, but he couldn't have done it without a regional housing crisis or his own landlord, who somehow collected rent for the building while remaining oblivious to - or unconcerned about - its flagrant misuse.

Beyond the pair of demolition contractors already sent to prison for the Philadelphia collapse, the victims are seeking recompense from Basciano; the architect his company hired to oversee the demolition, Plato Marinakos; and the Salvation Army officials who failed to warn their employees that they were at risk. Predictably, each of the defendants has sought to blame the others and deflect responsibility. Defense lawyers even bristled at an expert's suggestion that architects are ethically obligated to speak up for public safety.

The trial has underscored the absence of the party clearly assigned that duty: the city, which didn't manage to dispatch an inspector to the site while the demolition lurched toward its terrible conclusion. Meanwhile, in Oakland, city officials have yet to unearth evidence that a code enforcement official ever set foot inside the doomed warehouse.

Both catastrophes offer dark reminders that no city can be rid of the selfish, the careless, or the unscrupulous. The only bulwark against them are the cities themselves - and the laws they fail to enforce at our peril.