Skip to content

Instantly share code, notes, and snippets.

@mixin moose-tooltip($message) {
position: relative;
display: inline-block;
text-decoration: underline dotted blue;
&::before {
opacity: 0;
}
&:hover::before {
opacity: 1;
font-size: 0.8rem;
@paxperscientiam
paxperscientiam / promises.md
Created May 24, 2019 16:30 — forked from domenic/promises.md
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
(defun dsedivec/called-via-key-binding (cmd)
"Returns non-nil if `this-command-keys' is bound to CMD."
(eq (key-binding (this-command-keys)) cmd))
(defun moose/popup-count-words-region (start end)
"Get word count for positive length active region."
(interactive "r")
(cond ((and (use-region-p)
(dsedivec/called-via-key-binding #'moose/popup-count-words-region))
(defun moose/popup-count-words-region (start end &optional args)
"Get word count for positive length active region."
(interactive "r\np")
(cond ((and (use-region-p)
(eq this-command 'moose/popup-count-words-region))
(let ((print-escape-newlines t))
(popup-tip (concat (number-to-string (count-words start end)) " words"))))))
(defun moose/popup-count-words-region (start end)
"Get word count for positive length active region."
(interactive "r")
(cond ((and (use-region-p)
(> (region-end) (region-beginning))
(eq this-command 'moose/popup-count-words-region))
(let ((print-escape-newlines t))
(popup-tip (concat (number-to-string (count-words start end)) " words"))))))
;; all credit to someone else. use are your own peril!
;; search the closest Makefile and run make
;; not finished
;; 从当前目录向上查找最近的Makefile,并执行make命令
(defun get-parent-directory (path)
"get the parent directory"
(file-name-directory (directory-file-name path)))
(defun moose/test-compilation-buffer (buffer string)
"Return messages of success."
(if (and
(string-match "compilation" (buffer-name buffer))
(string-match "finished" string)
(not (search-forward "warning" nil t)))
(message "Compilation successful.")
(message "FAIL!")))
;; all credit to someone else. use are your own peril!
;; search the closest Makefile and run make
;; 从当前目录向上查找最近的Makefile,并执行make命令
(defun get-parent-directory (path)
"get the parent directory"
(file-name-directory (directory-file-name path)))
(defun compile-make-ex (target)
#!/usr/bin/env bash
function finish {
echo "I am complete."
}
trap finish EXIT
function rekt {
echo "Canceled."
exit
}
trap rekt SIGINT
#!/usr/bin/env bash
function finish {
echo "I am complete."
}
trap finish EXIT
function rekt {
echo "Canceled."
exit
}
trap rekt SIGINT