Skip to content

Instantly share code, notes, and snippets.

@katspaugh
katspaugh / index.js
Last active December 24, 2015 00:09
QuestHub Classifier. To run: npm install & npm test
/*
Document schema:
================
```
{
"ts": 1379926901,
"status": "open",
"_id": "524003755e1eff6b37000084",
"points": 2,
"name": "Apply naïve Bayes classification to tagged quests data",
(#("Downloads/" 0 1
(face completions-common-part)
1 2
(face
(completions-first-difference)))
#("Documents/" 0 1
(face completions-common-part)
1 2
(face
(completions-first-difference)))
;;; -*- lexical-binding: t; -*-
(require 'color)
(defvar active-window (frame-selected-window))
(defun active-window-lighten ()
(let ((bg (face-attribute 'default :background)))
(when (equal "unspecified-bg" bg)
(setq bg "white"))
(defvar ido-at-point-matches-list nil)
(defvar ido-at-point-prefix-point nil)
(defun ido-at-point-matches ()
ido-at-point-matches-list)
(defun ido-at-point-prefix ()
ido-at-point-prefix-point)
#!/usr/bin/env bash
set -e
function buildFile() {
psfile=$1
jsfile=${psfile/ps/js}
echo "Building $jsfile"
@katspaugh
katspaugh / ido-config.el
Created March 7, 2014 18:07
Displaying code completions through a graphical menu. Requires Emacs 24.4 and ido-at-point
(require 'ido-at-point)
(defun ido-at-point-x-prompt (prompt choices &optional display-fn)
"Display choices in a x-window prompt."
(when (and window-system choices)
(let ((chosen
(let (menu d) ;; d for display
(dolist (c choices)
(setq d (or (and display-fn (funcall display-fn c))
c))
@katspaugh
katspaugh / car.sh
Last active August 29, 2015 14:04
Raspberry Pi car-controlling bash script
#!/bin/bash
cd /sys/class/gpio
function left {
echo 4 > export
echo out > gpio4/direction
echo $1 > gpio4/value
echo 4 > unexport
}
@katspaugh
katspaugh / tern-lint.el
Created November 26, 2014 21:52
Flycheck-based tern-lint
;;; -*- lexical-binding: t -*-
;;; tern-lint.el --- JavaScript type-checker using tern-lint and flycheck.
;; Author: katspaugh
;; Keywords: tools
;; URL: https://github.com/katspaugh/tern-lint.el
;; Version: 0.0.1
;; Package-Requires: ((emacs "24") (tern "*"))
;;; Installation:
@katspaugh
katspaugh / coffee.js
Last active August 29, 2015 14:16
tern-coffee
var tern = require('tern');
var coffee = require('coffee-script');
var SourceMapConsumer = require('source-map').SourceMapConsumer;
var compile = function (source) {
return coffee.compile(source, {
bare: true,
sourceMap: true
});
@katspaugh
katspaugh / README.md
Last active August 29, 2015 14:20
Show the beginning of defun at point

This is an attempt to replicate a feature found in WebStorm:

When you are in the end of a block, and the beginning of the block is outside the viewport, it shows you the beginning in a nice overlay.

In Emacs we can show the beginning of function definition at point in the header line.