# Posting code on HTM Forum

**URL:** <https://discourse.numenta.org/t/posting-code-on-htm-forum/1412>\
**Category:** Site News\
**Tags:** protip\
**Created:** [September 19, 2016, 5:19pm UTC](https://discourse.numenta.org/t/posting-code-on-htm-forum/1412 "2016-09-19T17:19:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)\
**Post date:** [September 19, 2016, 5:19pm UTC](https://discourse.numenta.org/t/posting-code-on-htm-forum/1412/1 "2016-09-19T17:19:20Z")

</div>

A lot of people are posting code here on the forum, which is great, but can lead to really messy topics. Here are a few [markdown](http://commonmark.org/help/) pointers for creating readable code posts.

### Use code blocks for short snippets

Here’s an example of how to format some python code with triple backticks:

```auto
# Utility routine for printing the input vector
def formatRow(x):
  s = ''
  for c in range(len(x)):
    if c > 0 and c % 10 == 0:
      s += ' '
    s += str(x[c])
  s += ' '
  return s

```

All you have to do is add three backticks on a line by themselves before and after your code. Here is what the actual markdown text of the post looks like:

````
```
# Utility routine for printing the input vector
def formatRow(x):
  s = ''
  for c in range(len(x)):
    if c > 0 and c % 10 == 0:
      s += ' '
    s += str(x[c])
  s += ' '
  return s
```

````

#### Declare the programming language

You may also specify a programming language, like this:

```javascript
function deduplicateCollaborators(collaborators) {
    var foundLogins = [];
    return _.filter(collaborators, function (collaborator) {
        var duplicate = false
          , login = collaborator.login;
        if (foundLogins.indexOf(login) > -1) {
            duplicate = true;
        } else {
            foundLogins.push(login);
        }
        return ! duplicate;
    });
}

```

The forum software knows this is javascript because I told typed the word “javascript” immediately after the first set of backticks. The post text looks like this:

````
```javascript
function deduplicateCollaborators(collaborators) {
    var foundLogins = [];
    return _.filter(collaborators, function (collaborator) {
        var duplicate = false
          , login = collaborator.login;
        if (foundLogins.indexOf(login) > -1) {
            duplicate = true;
        } else {
            foundLogins.push(login);
        }
        return ! duplicate;
    });
}
```

````

### Use Gist or Pastebin for longer code blocks

If you have a large code block to paste, you can use [gist](https://gist.github.com/) or [pastebin](http://pastebin.com/) to store the code. When you paste the URL to those pages, they will embed nicely like this:

> <https://gist.github.com/rhyolight/86b46cd897fdfbff07036ef696f36ff3>

---

<div class="post-metadata">

**Author:** ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)\
**Post date:** [May 21, 2018, 3:11pm UTC](https://discourse.numenta.org/t/posting-code-on-htm-forum/1412/2 "2018-05-21T15:11:10Z")

</div>

Pinned globally on May 21, 2018, 3:11pm UTC


