Skip to content

Instantly share code, notes, and snippets.

BJ Terry BJTerry

View GitHub Profile
BJTerry / install-cgal-swig-bindings
Created Jun 15, 2016
How to install cgal-swig-bindings on Mac OS X with homebrew for Python
View install-cgal-swig-bindings
# This information was impossible to find
brew install cgal
brew install swig
git clone
cd cgal-swig-bindings
# Replace the python paths below with the correct version for your system
cmake -DCGAL_DIR=/usr/local/lib/CGAL \
BJTerry / gist:13477b152b8202f33d0c
Last active Aug 29, 2015
Make erlang-mode not double-indent after a fun ->
View gist:13477b152b8202f33d0c
(defun erlang-calculate-stack-indent (indent-point state)
"From the given last position and state (stack) calculate indentation.
Return nil if inside string, t if in a comment."
(let* ((stack (and state (car state)))
(token (nth 1 state))
(stack-top (and stack (car stack))))
(cond ((null state) ;No state
((nth 3 state)
;; Return nil or t.
BJTerry / gist:2f7594536dccc0ca4971
Created Apr 18, 2015
Using rainbow-identifiers-mode with php-mode
View gist:2f7594536dccc0ca4971
(setq rainbow-identifiers-faces-to-override (default font-lock-variable-name-face))
(defun rainbow-identifiers-face-overridable (begin end)
"Test if all the faces under the identifier are overridable."
(let ((current begin)
(contains-non-default nil))
(catch 'rainbow-identifiers--face-overridable
(while (progn
(let ((face (get-text-property current 'face)))
; In PHP function names have no style
BJTerry / python-prospector-flycheck.el
Created Nov 21, 2014
A flycheck checker for python with prospector
View python-prospector-flycheck.el
(flycheck-define-checker python-prospector
"A Python syntax and style checker using Prospector.
See URL `'."
:command ("prospector" "-s" "medium" "-M" "-o" "emacs"
((error line-start
(file-name) ":" (one-or-more digit) " :" (optional "\r") "\n"
(one-or-more " ") "L" line ":" column
(message (minimal-match (one-or-more not-newline)) "E" (one-or-more digit) (optional "\r") "\n"
BJTerry / gist:e0d55197ccf18ea562f9
Last active Aug 29, 2015
Workaround example for highmaps media query issue
View gist:e0d55197ccf18ea562f9
// Workaround for
// Uses default bootstrap media query sizes.
// display_heatmap is a function that displays the heatmap once the map data has been downloaded.
// Requires enquire.js (
// Download map data and save the jqXHR promise.
var states_promise = jQuery.getJSON('', {});
// Use enquire to re-render the heatmap if we change browser width
View states
State Cost Population Cost/Pop
PR $37,712,132.94 601,723 $62.67
DC $21,741,478.09 646,449 $33.63
GU $5,466,524.59 159,358 $34.30
AL $117,321,970.75 4,779,736 $24.55
DE $12,483,178.35 897,934 $13.90
TN $88,036,810.05 6,346,105 $13.87
FL $252,801,365.49 18,801,310 $13.45
NM $25,077,905.94 2,059,179 $12.18
SC $49,446,894.25 4,625,364 $10.69
BJTerry / gist:32b491dc30788ec371e9
Created Jul 5, 2014
A naive way to get JQuery slide/fade animations in React.js
View gist:32b491dc30788ec371e9
var JQuerySlide = React.createClass({
componentWillEnter: function(callback){
var $el = $(this.getDOMNode())
componentWillLeave: function(callback){
var $el = $(this.getDOMNode());
BJTerry / gist:5593180
Created May 16, 2013
A modification of the script at to prompt for a delay and minutes of control. If you want to set your own defaults, change the 180 or the 30 to whatever amount you want.
View gist:5593180
on run argv
set defaultTime to 1
set myTime to item 1 of argv as number
set myDelay to 0
on error
display dialog "Enter time to block in minutes" default answer 180
set myTime to (text returned of result) as number
display dialog "After how much time" default answer 30
BJTerry / gist:3693479
Created Sep 10, 2012
Code to fix ghc-mod, flymake, haskell-mode when used with yesod
View gist:3693479
;; Add this code to your .emacs file so it will be loaded at start, after installing ghc-mod
;; This code checks the parent folders of new haskell buffers to see if they contain .cabal
;; files. If so, it changes the working directory of the buffer to point to that directory.
(defun change-to-cabal-directory ()
(if (buffer-file-name)
(change-to-cabal-directory-from-directory (file-name-directory buffer-file-name))))
(defun change-to-cabal-directory-from-directory (directory)
You can’t perform that action at this time.