Hybrid Approach for Studying Defects and Electronic Properties: Cuprates and MgB2 Superconductors