Gists for embedding code

So, I might have found a slightly better method for sharing code in posts that I complained about the other day. GitHub has a thing called Gists. It’s like a tiny repository you can paste a code snippet into (or upload a source file). Once that’s done, you can just paste the URL of the Gist into WordPress – it recognises it and does this:

ForEach(0..<3) { number in
Button {
// flag was tapped
flagTapped(number)
} label: {
FlagView(flagOf: countries[number])
}
.rotation3DEffect(.degrees(flagSpinAmount[number]),
axis: (x: 0, y: 1, z: 0))
.opacity(flagOpacity[number])
.scaleEffect(flagScale[number])
.animation(.default, value: flagSpinAmount)
}
view raw 1.swift hosted with ❤ by GitHub

I came across this being used on a blog post (about using the camera in apps) from Gaspard Rosay.

Leave a comment