Skip to content

Sexy code snippet management? I take this once please!

5. June 2013

Since a while I gaze at the nice snippet management of bl.ocks.org but was not really able to do this on my own! Enough…I want to do this too…this management is too unclear!

bl.ocks.org is based on the snippet management via GitHub-Gists. I’m already slightly familiar with GitHub…this could work! But how do I manage these Gists…manually? No, that would not be a good alternative! So…I began to search for a cool, easily applicable tool…and…found a video, where the author describes code management as sexy. That sounds good…let’s have a look at it!

http://net.tutsplus.com/tutorials/tools-and-tips/sexy-code-snippet-management-with-gists/

Yes…this is exactly the way how I want to manage my snippets…it’s simple, quick, has version control and enables me to search in all snippets for a code fragment…I want to have this framework! Let’s set it up! (Ubuntu 12.04 LTS)

Install Sublime Text

(Source: http://akaul.de/sublime-text-2-einfache-installation-unter-ubuntu-12-04-precise-pangolin-und-11-10-natty-narwhal/)

sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text

***But sometimes…it has to be done manually: http://www.technoreply.com/how-to-install-sublime-text-2-on-ubuntu-12-04-unity/

Now we have to enable this editor to manage code snippets via Gist. (Source: http://arlando.net/blog/manage-snippets-on-sublimetext-gist/)

Install Package management on Sublime Text

(Source: http://wbond.net/sublime_packages/package_control/installation)

The automatic setup did not work for me so I managed it manually:

  1. Click the Preferences > Browse Packages… menu entry
  2. Navigate one folder backwards and then navigate into the Installed Packages folder
  3. Download Package Control.sublime-package and copy it into the Installed Packages directory
  4. Restart Sublime Text
  5. Run the Package Control: Add Repository command via the command palette (Ctrl+Shift+P) and enter the following URL: https://sublime.wbond.net/alpha/packages.json
  6. Run the Package Control: Upgrade Package command and select Package Control from the list
  7. Restart Sublime Text

Install Gist on Sublime Text

(Source: https://github.com/condemil/Gist)

  1. Open the command palette: Package Control: Install Package
  2. Search for ‘Gist’ and install it
  3. This was successfull when you find ‘Gist’ in the command palette, afterwards
  4. Set up the necessary initial GitHub user values:
    1. Preferences –> Browse Packages… –> open ‘Gist‘ –> open ‘Gist.sublime-settings
    2. define your ‘username’, ‘password’
    3. We also have to define a ‘token’ –> therefore we need a token: Ctrl+Alt+T –> execute:
      curl -v -u username -X POST https://api.github.com/authorizations --data "{\"scopes\":[\"gist\"]}"
    4. This throws out many lines (see in source how success looks like) –> copy/paste the ‘token’ to the settings file
  5. That’s it…test it!

Test framework

  1. open a file or make a new one
  2. command palette: Gist: Create Public/Private Gist
  3. give it a good pregnant description (its sense is described in the video at around 4:00)
  4. (obligatory) set/not set a filename
  5. check it out on the web: Gist: Open Gist in Browser
  6. check it out in sublime text: Gist: Open Gist –> that gives you a list of all your Gists

Now we’ve got the same framework, like described in the video.

I began this post by mentioning bl.ocks.org…in a recent post we will see what has to be done to easily visualise snippets, additionally.

Advertisements
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: