Skip to content

Instantly share code, notes, and snippets.

View mrc's full-sized avatar

Matt Curtis mrc

  • Melbourne
View GitHub Profile
@mrc
mrc / waitForKeyElements.js
Created July 5, 2019 19:13 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
-module(index).
-export([get_file_contents/1,show_file_contents/1, index/1, index_map/1, index_helper/3, add_line_number/2]).
% Used to read a file into a list of lines.
% Example files available in:
% gettysburg-address.txt (short)
% dickens-christmas.txt (long)
% Get the contents of a text file into a list of lines.
-module(assignment).
-export([area/1, perimeter/1, enclose/1,
testArea/0, testPerimeter/0, testEnclose/0,
bits/1, bitsDirect/1, bitsTailRecursive/1,
testBits/0,
testAll/0, allTestsPass/0]).
%% circle: {circle, Radius}
%% square: {square, Length}
%% rectangle: {rectangle, Length, Width}
@mrc
mrc / ine.zsh
Created May 2, 2016 02:20
Copy stdin to emacsclient
function ine() {
local tmpfile
tmpfile=$(mktemp "ine-XXXX.${1:-tmp}")
echo "$tmpfile"
touch "$tmpfile"
tee "$tmpfile"
emacsclient -n "$tmpfile"
( sleep 5 ; rm "$tmpfile" ) &
}
@mrc
mrc / live-cricket-score.el
Created February 2, 2014 12:43
Emacs: Retrieve a page from cricinfo and extract the score from the title
(require 'deferred)
(require 'request)
(require 'request-deferred)
(defun extract-title ()
(goto-char (point-min))
(let* ((start-string "<title>")
(end-string "</title>")
(start (search-forward start-string))
(end (- (search-forward end-string) (length end-string))))
@mrc
mrc / mrc-helm-context-info.el
Created February 2, 2014 03:37
Context-sensitive info index lookup with helm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; helm info
(defvar mrc-helm-context-info-alist
'(((emacs-lisp-mode lisp-interaction-mode inferior-emacs-lisp-mode)
. (helm-source-info-elisp helm-source-info-cl helm-source-info-emacs))
((org-mode) . (helm-source-info-org))
((lisp-mode) . ((name . "Hyperspec") (info-index . "ansicl")
((name . "Iterate") (info-index . "iterate")))))
"Alist of modes to Helm sources.
@mrc
mrc / gist:8021085
Created December 18, 2013 11:50
"And what was terrifying was not that they would kill you for thinking otherwise, but that they might be right."
% python
Python 2.7.5 (default, Jun 4 2013, 21:44:14)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 2+2
5
' '.join([w for i,w in enumerate(sentence.split(),1) if i in (17,23)])
@mrc
mrc / org-table-kill-column.el
Created April 30, 2013 07:51
Kill a column in an org-mode table (clipboard driven development at it's finest; a renovator's dream)
(defun org-table-kill-column (margin-width)
"Kill a column from the table.
Cut in on each side by MARGIN-WIDTH; use 0 to keep the column delimiters."
(interactive "p")
(if (not (org-at-table-p))
(error "Not at a table"))
(org-table-find-dataline)
(org-table-check-inside-data-field)
(kill-new "")
(let* ((col (org-table-current-column))
@mrc
mrc / flipflopwheel
Created April 30, 2013 07:47
Windows: Invert mouse wheel scrolling direction (to match OS X Lion)
#+begin_example
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\HID\VID_046D&PID_C016\8&366fb2e2&0&0000\Device Parameters
#+end_example
[[http://superuser.com/questions/310681/inverting-direction-of-mouse-scroll-wheel]]