In my most recent post about installing Ubuntu/Swift, I glancingly referred in a screenshot to pulling swift source from a github gist. I thought it was useful enough a tip to pull out to its own post.
Say you have a gist, for example: this one, which is located at gist.github.com/erica/4d31fed94f3668342623. I threw this sample together to help some Linux-ers work with incomplete Foundation and Standard Library implementations on Ubuntu.
If you grab this link’s content from the terminal command-line using curl, you’ll end up with the page’s HTML source, which is pretty much not what you want to compile:
Instead, replace gist.github.com with gist.githubusercontent.com and append /raw to the url:
https://gist.githubusercontent.com/erica/4d31fed94f3668342623/raw
This adjusted URL bypasses the HTML page contents and accesses the raw text stored within the gist. Just redirect with > into a Swift file and you’re ready to compile.
I hope this tip helps minimize the misery of sharing code with Ubuntians.
Comments are closed.