Skip to content

Instantly share code, notes, and snippets.

@bradwright
bradwright / erc-mode.el
Created March 15, 2012 13:51
ERC configuration
;; erc configuration for IRC
(require 'erc)
(require 'erc-services nil t)
(erc-services-mode 1)
;; don't show join/part etc.
(setq erc-hide-list '("JOIN" "PART" "QUIT" "NICK"))
@bradwright
bradwright / index.jinja
Created March 6, 2012 09:42
Flask-MustacheJS integration
<!doctype html>
<html>
<head>
<title>Example</title>
<script type="text/javascript" src="{{ url_for('mustache.static', filename='mustache-loader.js') }}"></script>
{{ mustache_templates }}
</head>
<body>
</body>
</html>
@bradwright
bradwright / preorders.eml
Created March 2, 2012 10:44
Gameplay Mass Effect 3 preorders
Hi,
Thank you for your email.
Unfortunately we are not in a position to supply you with your copy of
Mass Effect 3. As dedicated gamers, we know how disappointing this
will be for you, and we apologise sincerely for the inconvenience that
this will cause.
@bradwright
bradwright / compiled-hogan.js
Created February 29, 2012 22:20
Compiled Hogan.js files
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
from flask import current_app
import pystache
@template_helper
def mustache(template, **kwargs):
"""Usage:
{{ mustache('path/to/whatever.mustache', key=value, key1=value1.. keyn=valuen) }}
"""
template, _, _ = current_app.jinja_loader.get_source(current_app.jinja_env, template)
return pystache.render(template, kwargs, encoding='utf-8')
@bradwright
bradwright / date_helper.py
Created February 20, 2012 17:14
Django date template helpers without relying on Django
# Django licence
"""
Copyright (c) Django Software Foundation and individual contributors.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
@bradwright
bradwright / custom-theme-dirs.el
Created February 16, 2012 08:00
Get all directories under a certain one
;; add all theme directories to the `custom-theme-load-path`
;; directory automatically so `load-theme` can find them.
(let ((base "/home/user/.emacs.d/vendor/themes"))
(add-to-list 'custom-theme-load-path base)
(dolist (f (directory-files base))
(let ((name (concat base "/" f)))
(when (and (file-directory-p name)
(not (equal f ".."))
(not (equal f ".")))
(add-to-list 'custom-theme-load-path name)))))
@bradwright
bradwright / darwin-keychain.el
Created February 12, 2012 11:39
How to get an OS X KeyChain entry in Emacs (useful for ERC etc.)
(defun chomp (str)
"Chomp leading and tailing whitespace from STR."
(while (string-match "\\`\n+\\|^\\s-+\\|\\s-+$\\|\n+\\'" str)
(setq str (replace-match "" t t str))) str)
(defun get-keychain-password (account-name)
"Gets `account` keychain password from OS X Keychain"
(chomp
(shell-command-to-string
(concatenate
@bradwright
bradwright / site.css
Created January 18, 2012 07:18
Stop SOPA stopping Wikipedia
/* this kills the overlay and restores regular Wikipedia divs to action. */
div#mw-sopaOverlay {
display: none;
}
#mw-page-base, #mw-head-base, #content, #mw-head, #mw-panel, #footer {
display: block;
}
@bradwright
bradwright / djangojinja.py
Created November 29, 2011 12:13
Django and Jinja together at last
# -*- coding: utf-8 -*-
"""
djangojinja2
~~~~~~~~~~~~
Adds support for Jinja2 to Django.
Configuration variables:
======================= =============================================