Skip to content

Instantly share code, notes, and snippets.

@febeling
Created June 26, 2014 12:09
Show Gist options
  • Save febeling/3022a80cf8a151cc29ce to your computer and use it in GitHub Desktop.
Save febeling/3022a80cf8a151cc29ce to your computer and use it in GitHub Desktop.

Ruby example

This is a text part.

def name
  "Org"
end
puts name

More text.

Elisp example

12345678910
2468101214161820
(defun fibonacci (n)
  (if (or (= n 0) (= n 1))
      n
    (+ (fibonacci (- n 1)) (fibonacci (- n 2)))))

(mapcar (lambda (row)
          (mapcar #'fibonacci row)) fib-inputs)

Inline code blocks

Without header args: src_lang{code} or with header args: src_lang[args]{code}, for example src_ruby{x = 10*3; puts “x is ” + x.to_s; x} 30, where x is a variable existing in the python session.

x*x

Mix languages

cd ~ && du -sc * | grep -v total
pie(dirs[,1], labels = dirs[,2])
@febeling
Copy link
Author

The literate programming examples from yesterday night.

Some setup was also necessary to be able to evaluate ruby, shell, R, etc. There is a variable org-babel-load-languages, which i customized:

(org-babel-do-load-languages
 'org-babel-load-languages
 '((R . t)
   (ruby . t)
   (python . t)
   (sh . t)))

Before I also eval'd a package, ob-ruby.el – but I'm not sure if that would have been necessary with above variable setting.

(For using gist.el see also this comment if you use 2AF: defunkt/gist.el#51 (comment))

Attn @plexus

Proudly posted using gist.el :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment