Skip to content

Instantly share code, notes, and snippets.

View telotortium's full-sized avatar

Robert Irelan telotortium

  • Google, Inc.
  • Mountain View, CA
View GitHub Profile
;;;; From https://blog.aaronbieber.com/2016/03/05/playing-tag-in-org-mode.html
(defun air--org-swap-tags (tags)
"Replace any tags on the current headline with TAGS.
The assumption is that TAGS will be a string conforming to Org Mode's
tag format specifications, or nil to remove all tags."
(let ((old-tags (org-get-tags-string))
(tags (if tags
(concat " " tags)
"")))
@telotortium
telotortium / slatestarcodex-only-expand-new-comments.js
Last active June 15, 2017 22:58
slatestarcodex.com - Collapse all comments except new comments and their ancestors
javascript:!function(){var e=document.querySelectorAll(".commentholder a.comment-hide-link");(e=Array.prototype.slice.call(e)).reverse(),e.forEach(function(e){"Hide"==e.text&&commentToggle.call(e)});var o=document.querySelectorAll(".commentholder.new-comment");(o=Array.prototype.slice.call(o)).forEach(function(e){var o=[];for(comment=e;null!=comment;){o.unshift(comment);var t=comment.parentElement.closest(".comment");if(null!=t&&comment.classList.contains("depth-5")){var c=t.querySelectorAll(".comment.depth-5");o=o.concat(Array.prototype.slice.call(c))}comment=t}o.forEach(function(e){var o=e.querySelector(".commentholder a.comment-hide-link");"Show"==o.text&&commentToggle.call(o)})})}();

Keybase proof

I hereby claim:

  • I am telotortium on github.
  • I am telotortium (https://keybase.io/telotortium) on keybase.
  • I have a public key ASC8vnPgw7QTEovVVKh_9_8LCjUrSP1J5iPjS0ZM7WnDRgo

To claim this, I am signing this object:

@telotortium
telotortium / gist:8195450
Created December 31, 2013 11:18
append extension to Rust Path
// Append an extension to a `std::path::Path`.
//
// append_extension(Path::new("/path/to/file.txt"), Some("gz"))
// == Path::new("/path/to/file.txt.gz")
fn append_extension(path: Path, ext: Option<&str>) -> Path {
let orig_ext = path.extension_str();
let combined_ext_comps: ~[&str] = [orig_ext, ext].iter()
.filter_map(|&x| x).map(|x| x.clone()).collect();
let combined_ext = combined_ext_comps.connect(".");
path.with_extension(combined_ext.as_slice())