Those notes are from quite an old version of Julia (0.4) — that’s not how the diagm function is called anymore. An updated version of that function would be simply:
using LinearAlgebra
diff1(M) = let o = ones(M); diagm(M+1, M, 0=>o, -1=>-o); end
(And here is a sparse version using spdiagm.)