Skip to content

Instantly share code, notes, and snippets.

View sachac's full-sized avatar

Sacha Chua sachac

View GitHub Profile
var secret = require("./secret");
var flickrOptions = secret.flickrOptions;
var Flickr = require("flickrapi");
exports.trimTitle = function(str) {
return str.replace(/ --.*$/g, '').replace(/#[^ ]+/g, '').replace(/[- _]/g, '');
};
var hash = {};
(defun sacha/org-count-tasks-by-status ()
(interactive)
(let ((counts (make-hash-table :test 'equal))
(today (format-time-string "%Y-%m-%d" (current-time)))
values)
(org-map-entries
(lambda ()
(let* ((status (elt (org-heading-components) 2)))
(when status
(puthash status (1+ (or (gethash status counts) 0)) counts))))
@sachac
sachac / Sacha.el
Last active August 29, 2015 14:12
Sorting sexps alphabetically. May be handy for finding accidental duplicates.
(defun sacha/sort-sexps-in-region (beg end)
"Can be handy for sorting out duplicates.
Sorts the sexps from BEG to END. Leaves the point at where it
couldn't figure things out (ex: syntax errors)."
(interactive "r")
(let ((input (buffer-substring beg end))
list last-point form result)
(save-restriction
(save-excursion
(narrow-to-region beg end)
  • What are outlines good for?
    • Capturing thoughts quickly
    • Writing non-linearly
    • Roughly organizing your thoughts
    • Deciding depth and coverage
    • Rearranging them for a more logical flow
    • Writing quickly
    • Picking things up where you left off
    • Seeing the gaps
    • Simplifying
@sachac
sachac / gist:60989ef6f0a76da126fc
Created December 4, 2014 14:45
Source for my monthly review for November 2014

Monthly review: November 2014

I wrote last month that in November, I planned to:

  • Get team members up to speed with prototype designs and reporting tips
@sachac
sachac / gist:9aae1e34bb6f4d6d1299
Last active August 29, 2015 14:01
Gnus BBDB Salutations
;; This version is for BBDBv3 - thanks, Thomas!
(defvar wicked/gnus-nick-threshold 5 "*Number of people to stop greeting individually. Nil means always greet individually.") ;; (1)
(defvar wicked/bbdb-hello-string "Hello, %s!" "Format string for hello. Example: \"Hello, %s!\"")
(defvar wicked/bbdb-hello-all-string "Hello, all!" "String for hello when there are many people. Example: \"Hello, all!\"")
(defvar wicked/bbdb-nick-field 'nick "Symbol name for nickname field in BBDB.")
(defvar wicked/bbdb-salutation-field 'hello "Symbol name for salutation field in BBDB.")
(defun wicked/gnus-add-nick-to-message ()
"Inserts \"Hello, NICK!\" in messages based on the recipient's nick field."
@sachac
sachac / gist:0eb152c9ffe74cd2fe23
Last active August 29, 2015 14:01
Notes for ILC talk?

Title: Taking over the world, two parentheses at a time

How can we get more people to use and love Lisp? Come to this session for practical tips on applied selfishness and community-building, and join in the conspiracy to take over the world (or a reasonable portion thereof). I’ll share some stories from Emacs evangelism, including new tools, beginner-friendly approaches, and the effectiveness of indirect brainwashing.

Bio: Sacha Chua loves getting Emacs to do all sorts of things that boggle casual passers-by. She’s working on more resources for Emacs beginners and enthusiasts, including doodled cheat sheets and interviews with people who are even more into Emacs Lisp than she is (emacslife.com). You can check out her blog at LivingAnAwesomeLife.com or follow her on Twitter (@sachac).

@sachac
sachac / gist:11090358
Last active August 29, 2015 14:00
Little snippet to run command in term instead of inserting in region
(defadvice org-babel-execute:sh (around sacha activate)
  (if (assoc-default :term (ad-get-arg 1) nil)
    (let ((buffer (make-term "babel" (or explicit-shell-file-name
                                         (getenv "ESHELL")
                                         (getenv "SHELL")
                                         "/bin/sh"))))
      (with-current-buffer buffer
        (insert (org-babel-expand-body:generic
             body params (org-babel-variable-assignments:sh params)))
;; Totally untested
(defvar clarissa/beeminder-user "example" "Username for Beeminder service.")
(defvar clarissa/beeminder-token "1234" "Token - get this from https://www.beeminder.com/api/v1/auth_token.json")
(defun clarissa/beeminder-post (goal datapoint)
(interactive "MGoal: \nMData: \nMToken value: ")
(let ((url-request-data (json-encode `((value . ,datapoint) (auth_token . ,clarissa/beeminder-token))))
(url-request-method "POST")
(url-request-extra-headers '(("Content Type" . "application/json")))
(url-mime-encoding-string "identity"))
@sachac
sachac / term-management-tools.merge-tags-when-converting.diff
Created August 27, 2013 17:46
Term management tools - silently merge tags when converting
diff -u ./term-management-tools/term-management-tools.orig.php ./term-management-tools/term-management-tools.php
--- ./term-management-tools/term-management-tools.orig.php 2013-08-27 13:06:32.000000000 -0400
+++ ./term-management-tools/term-management-tools.php 2013-08-27 13:43:24.000000000 -0400
@@ -175,6 +175,17 @@
);
}
+ $term2 = get_term_by('name', $term->name, $new_tax);
+ if ($term2) {
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->term_relationships SET term_taxonomy_id=%d WHERE term_taxonomy_id=%d",