This file contains hidden or 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 RapidSMSLexer(RegexLexer): | |
""" | |
Lexer for RapidSMS text messages. | |
""" | |
name = 'RapidSMS' | |
aliases = ['sms'] | |
filenames = [] | |
mimetypes = ['application/x-rapidsms'] |
This file contains hidden or 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 SomeArchetypeWithImages(...): | |
def __bobo_traverse__(self, REQUEST, name): | |
if name in self.image_field_ids: | |
field = self.getField(name) | |
image = field.getScale(self) | |
else: | |
# decode request | |
parts = name.split('_') | |
field_name = '_'.join(parts[:-1]) | |
scale = len(parts) > 1 and parts[-1] or None |
This file contains hidden or 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
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
import sys | |
import StringIO | |
f = open(sys.argv[1], 'r') | |
g = iter(f) | |
default = None |
This file contains hidden or 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
import imp | |
import sys | |
def create_modules(module_path): | |
path = "" | |
module = None | |
for element in module_path.split('.'): | |
path += element | |
try: |
This file contains hidden or 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 z3c.form import form | |
from z3c.form import field | |
from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper | |
from plone.app.textfield.value import RichTextValue | |
from plone.z3cform import layout | |
from Products.CMFCore.utils import getToolByName | |
class IMyFormSchema(Interface): | |
text = RichText(title=u"Text", required=False, default=u"") |
This file contains hidden or 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 zope.component import getUtility | |
from zope.interface import Interface | |
from zope.interface import alsoProvides | |
from plone.registry.interfaces import IRegistry | |
from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper | |
from plone.app.registry.browser.controlpanel import RegistryEditForm | |
from plone.z3cform import layout |
This file contains hidden or 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
#!/bin/bash | |
if [ ! -d $1 ]; then | |
echo "Not a directory: $1" | |
exit -1 | |
fi | |
while read line; do | |
filename="$(basename $line)" | |
if [ "${filename##*.}" == "less" ]; then |
This file contains hidden or 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
import os | |
import re | |
from htmlentitydefs import name2codepoint | |
# Must install the `hyphenator` library from PyPi! | |
from hyphenator import Hyphenator | |
# Firefox comes with an English hyphenation dictionary | |
path = os.popen('locate hyph_en_US.dic').readlines()[0].strip() |
This file contains hidden or 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 nuke-dashes () | |
(interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward "^-" nil t) (replace-match "")))) | |
(global-set-key "\C-d" 'nuke-dashes) |
This file contains hidden or 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
;; .emacs | |
;; ========================================================================= | |
;; | |
;; Malthe Borch | |
;; | |
;; Last updated: Fri Feb 24, 2012. | |
;; Add own packages to load path | |
(let* ((my-lisp-dir "~/.emacs.d/site-lisp") | |
(default-directory my-lisp-dir) |
OlderNewer