Aaron Parecki

  • Articles
  • Notes
  • Photos
  • Owning my Code Snippets

    January 6, 2018

    It's very convenient to be able to quickly share a link to a code snippet, which is something I've mostly done using gist.github.com. While often the code snippets are sort of throwaway, I still feel bad that I'm posting them in a place that I don't control.

    Today I added support to my site for natively posting code snippets. It wasn't nearly as hard as I was imagining it was going to be! Since my site doesn't have a posting interface of its own, that also meant that I needed to add support to Quill to create these posts via Micropub.

    Since this is still relatively experimental, I didn't add a button to it in Quill, but the page is live.

    The only required part of this is the code box. The interface lets you optionally set a filename, which will automatically set the language if it matches a list of known languages. The language is included in order to indicate to my site which syntax highlighter to use. Here's what that ends up looking like on my site.

    I use the GeSHi syntax highlighter, which covers a wide range of languages and works very well, but I'm not super happy with the colors it uses. I'd like to find a stylesheet or even a different syntax highlighter that looks closer to the colors on GitHub. In the mean time, I'm happy enough with this to use it.

    I ended up doing quite a bit of fiddling with my CSS to make these posts look good. You'll notice the grey background of the code block extends to the edges of the post, whereas normally there would be some padding. I also changed the font of the post name to a fixed-width font. If there is no filename, then I wanted the grey background to extend to the top of the frame, which is also something unique to these posts.

    The last step of making this actually useful is to integrate this into my browser workflow, including editing the posts easily. There is a bookmarklet that will either open up a new window or launch the editing interface depending on whether I'm looking at an existing code post.

    I'm pretty happy with this, and I hope I don't post on GitHub anymore unless I'm specifically using their fork feature of Gists!

    Portland, Oregon • 49°F
    #p3k #indieweb #code
    Sat, Jan 6, 2018 2:49pm -08:00
    1 reply 4 mentions
    • Anonymous commentpara.de/user/3.htm
      I use phorkie for self-hosting pastes and it supports forking github gists :) Example: http://p.cweiske.de/146
      Sun, Jan 7, 2018 5:04am -08:00

    Other Mentions

    • Nichole Renee twitter.com/Peaceful1979
      stackoverflow.com/questions/3580… pythonstudio.us/pyqt-programmi… insights.dice.com/2014/09/23/loo… learning-python.com/pymailgui-prod… doc.qt.io/archives/qt-4.… aaronparecki.com/2018/01/06/13/… ryadel.com/en/displaying-…
      Sat, Mar 21, 2020 4:31am +00:00 (via brid-gy.appspot.com)
    • Eddie Hinkle eddiehinkle.com
      Owning my code snippets
      Mon, Nov 5, 2018 5:42pm -05:00
    • Aaron Parecki aaronparecki.com
      First Quarter 2018 in Review
      Sun, Apr 1, 2018 4:42pm -07:00
    • Chris chrisbeckstrom.com
      Replied to reply to https://aaronparecki.com/2018/01/06/13/code-snippets

      This is great, thanks for creating such a useful tool! Do you also host your own git repo, and if so, how do you integrate that into your website?

      I use gitlist (https://github.com/klaussilveira/gitlist) but it’s not integrated into my site at all.

      Also on:
      Sun, Apr 1, 2018 8:22pm +00:00
Posted in /articles using quill.p3k.io

Hi, I'm Aaron Parecki, Senior Security Architect at Okta, and co-founder of IndieWebCamp. I maintain oauth.net, write and consult about OAuth, and participate in the OAuth Working Group at the IETF. I also help people learn about video production and livestreaming and dabble in product design.

I've been tracking my location since 2008 and I wrote 100 songs in 100 days. I've spoken at conferences around the world about owning your data, OAuth, quantified self, and explained why R is a vowel. Read more.

  • Security Architect at Okta
  • IndieWebCamp Founder
  • OAuth WG Member

  • 🎥 YouTube Tutorials and Reviews
  • 🏠 We're building a triplex!
  • ⭐️ Life Stack
  • ⚙️ Home Automation
  • All
  • Articles
  • Bookmarks
  • Notes
  • Photos
  • Replies
  • Reviews
  • Trips
  • Videos
  • Contact
© 1999-2023 by Aaron Parecki. Powered by p3k. This site supports Webmention.
Except where otherwise noted, text content on this site is licensed under a Creative Commons Attribution 3.0 License.
IndieWebCamp Microformats Webmention W3C HTML5 Creative Commons
WeChat ID
aaronpk_tv