This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Window resizing crap | |
(global-set-key (kbd "S-C-<left>") 'shrink-window-horizontally) | |
(global-set-key (kbd "S-C-<right>") 'enlarge-window-horizontally) | |
(global-set-key (kbd "S-C-<down>") 'shrink-window) | |
(global-set-key (kbd "S-C-<up>") 'enlarge-window) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def monkeypatch(target, name = None, func = None, backup_prefix = "default_"): | |
''' | |
Decorator. | |
Binds target.name = func | |
Creates target.{backup_prefix + name} = target.name if property exists. | |
This allows the patched properties to depend on the existence of the original | |
property on the target. | |
''' | |
if not func: return lambda func: monkeypatch(target, name, func) | |
if not name and func.__name__[0] is not '<': name = func.__name__.strip('_') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_consuming_chain(*functions, **kwargs): | |
''' | |
Return a function that will call functions in sequence, passing the return down the chain of functions | |
''' | |
return reduce(lambda acc, f: lambda *args, **kwargs: f(acc(*args, **kwargs)), functions) | |
def make_chainable(method): | |
''' | |
Make a method returning none return self | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun toggle-dedicate () | |
(interactive) | |
(set-window-dedicated-p (selected-window) | |
(not (window-dedicated-p (selected-window))))) | |
(global-set-key [(control c) (shift d)] 'toggle-dedicate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Example fragments, extra magic withheld | |
window.fragments = { | |
name: { | |
url: context.project_property_url.to_project_url().to_property_url('name'), | |
location: '.project_title' | |
}, | |
background: { | |
_interval: 60000, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class State(object): | |
transitions = [] | |
def __init__(self, *transitions_or_data): | |
if len(transitions_or_data) and reduce(lambda acc, e: acc and type(e) == Transition, transitions_or_data, True): | |
type(self).transitions = transitions_or_data | |
else: | |
self.data = { | |
1: lambda: transitions_or_data[0], | |
0: lambda: None, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.urlresolvers import reverse | |
from django.views.decorators.http import require_POST | |
from django.http import HttpResponseRedirect, HttpResponseNotAllowed | |
def require_POST_or(other): | |
def _d_closure(func): | |
def wrapped_func(request, *args, **kwargs): | |
r = require_POST(func)(request, *args, **kwargs) | |
if type(r) == HttpResponseNotAllowed: | |
if callable(other): return other(request, *args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mapchain(*functions_then_list): | |
''' | |
mapchain(f..fn, list) | |
Map the functions in sequence from left to right across list | |
mapchain(f1, f2, f3, f4, list) => map(f4, map(f3, map(f2, map(f1, list)))) | |
''' | |
if len(functions_then_list) < 2: raise TypeError("mapchain(f..fn, list) requires at least one function and a list") | |
ops, items = functions_then_list[0:-1], functions_then_list[-1] | |
if not reduce(lambda a, b: a and b, map(callable, ops), True): raise TypeError("All but the list must be callable") | |
return reduce(lambda a, b:\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Run a emacs repl with yaws loaded and configured | |
(defvar yaws-path "~/Applications/YAWS") | |
(defun run-erlang-yaws () | |
(interactive) | |
(let ((inferior-erlang-machine-options `("+K" "true" | |
"-pa" ,(concat yaws-path "/lib/yaws/ebin") | |
"-yaws" "debug" | |
"-run" "yaws" | |
"-yaws" "id" "default"))) | |
(run-erlang))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'cl) | |
(require 'erlang-start) | |
;; Run a emacs repl with yaws loaded and configured | |
(defvar yaws-path "~/Applications/YAWS") | |
(defvar yaws-listening-regex "Yaws: Listening") | |
(defvar yaws-extra-paths ()) | |
(defvar yaws-extra-flags ()) | |
(defadvice inferior-erlang-wait-prompt (before send-ret-before-waiting last () activate) |
OlderNewer