Skip to content

Instantly share code, notes, and snippets.

View sachac's full-sized avatar

Sacha Chua sachac

View GitHub Profile
@sachac
sachac / Sacha.el
Last active August 29, 2015 14:13
(defun sacha/copy-code-as-org-block-and-gist (beg end)
(interactive "r")
(let ((filename (file-name-base))
(mode (symbol-name major-mode))
(contents
(if (use-region-p) (buffer-substring beg end) (buffer-string)))
(gist (if (use-region-p) (gist-region beg end) (gist-buffer))))
(kill-new
(format "\n[[%s][Gist: %s]]\n#+begin_src %s\n%s\n#+end_src\n"
(oref (oref gist :data) :html-url) filename
/**
* Upload the file to my Flickr sketchbook and then moves it to
* Dropbox/Inbox/To blog. Save the Org Mode links in the clipboard. -
* means the photo already existed, + means it was uploaded.
*/
var async = require('async');
var cp = require('child_process');
var fs = require('fs');
var glob = require('glob');
**Getting started with Emacs? Empty your cup.**
Struggling with learning Emacs because you're just not as productive as you are with your old editor? Copying configuration snippets from the Web in order to force it to work like what you're used to, but running into problems with conflicting code or obscure error messages?
Here's something I've realized. To learn Emacs well, you need to empty your cup. This is the story as told on the [C2 wiki](http://c2.com/cgi/wiki?EmptyYourCup):
<blockquote>A master was trying to explain something to a student. Now this student was not a brand new student, but a senior student who had learned many things. He had knowledge and experience aplenty to draw upon. But each time the master tried to explain something new to the student, the student kept trying to hold it up against his own notions of the way the world is and how it ought be, and he was unable to see the lessons in what the master was trying to teach him.
Finally, the master poured a full serving of tea into his

(defun sacha/open-urls-in-region (beg end) “Open URLs between BEG and END.” (interactive “r”) (save-excursion (save-restriction (narrow-to-region beg end) (goto-char (point-min)) (while (re-search-forward org-plain-link-re nil t) (org-open-at-point)))))

(defun sacha/copy-code-as-org-block-and-gist (beg end)
  (interactive "r")
  (let ((filename (file-name-base))
        (mode (symbol-name major-mode))
        (contents
         (if (use-region-p) (buffer-substring beg end) (buffer-string)))
        (gist (if (use-region-p) (gist-region beg end) (gist-buffer))))
    (kill-new
     (format "\n[[%s][Gist: %s]]\n#+begin_src %s\n%s\n#+end_src\n"
* Inbox of sketches to classify or write about
- Learning
- [[https://www.flickr.com/photos/sachac/16180954156/][2015.01.04 Rhythm for learning -- index card]]
- [[https://www.flickr.com/photos/sachac/16052554957/][2015.01.08 Learning as an event -- index card]]
- [[https://www.flickr.com/photos/sachac/16052554877/][2015.01.09 Cross-pollination of ideas -- index card]]
- [[https://www.flickr.com/photos/sachac/16077216200/][2015.01.12 How I stopped looking for answers -- index card #reading]]
- [[https://www.flickr.com/photos/sachac/16077215930/][2015.01.12 What am I learning about -- index card #plans]]
- Emacs
- [[https://www.flickr.com/photos/sachac/16206810125/][2015.01.03 Why Emacs -- index card]]
/**
* Adds "Blogged" links to Flickr for images that don't yet have "Blogged" in their description.
* Command-line argument: URL to retrieve and parse
*/
var secret = require('./secret');
var flickrOptions = secret.flickrOptions;
var Flickr = require("flickrapi");
var fs = require('fs');
var request = require('request');
(ert-deftest sacha/org-capture-prefill-template ()
(should
;; It should fill things in one field at a time
(string=
(sacha/org-capture-prefill-template
"* TODO %^{Task}\nSCHEDULED: %^t\n:PROPERTIES:\n:Effort: %^{effort|1:00|0:05|0:15|0:30|2:00|4:00}\n:END:\n%?\n"
"Hello World")
"* TODO Hello World\nSCHEDULED: %^t\n:PROPERTIES:\n:Effort: %^{effort|1:00|0:05|0:15|0:30|2:00|4:00}\n:END:\n%?\n"
))
(should
@sachac
sachac / flickr-upload.js
Created May 15, 2015 01:52
flickr-upload.js
/**
* Upload the file to my Flickr sketchbook and then moves it to
* Dropbox/Inbox/To blog. Save the Org Mode links in the clipboard. -
* means the photo already existed, + means it was uploaded.
*/
var async = require('async');
var cp = require('child_process');
var fs = require('fs');
var glob = require('glob');