Skip to content

Instantly share code, notes, and snippets.

View markvl's full-sized avatar

Mark van Lent markvl

View GitHub Profile

Keybase proof

I hereby claim:

  • I am markvl on github.
  • I am markvl (https://keybase.io/markvl) on keybase.
  • I have a public key whose fingerprint is 1FFA 3F2D 26D6 B7FB AED7 FE5F 2144 528D 8811 0619

To claim this, I am signing this object:

@markvl
markvl / gist:3884023
Created October 13, 2012 10:03
build_i18n.sh
#!/bin/sh
#
# Shell script to manage .po files.
#
# Run this file in the folder main __init__.py of product
#
# Copyright 2010 mFabrik http://mfabrik.com
#
# http://plone.org/documentation/manual/plone-community-developer-documentation/i18n/localization
# New location: http://collective-docs.readthedocs.org/en/latest/i18n/internationalisation.html#managing-po-files
@markvl
markvl / example.md
Created June 3, 2012 12:29
smartypants behaviour

Here's an example where I want the dashes to be replaced: 1--2. And---as is to be expected---here as well.

This doesn't work because I don't want them replaced: decrement-- and --parameter.

But if I use a code block, they won't be replaced: decrement-- and --parameter

Or like this:

def foo():

@markvl
markvl / blogentry.js
Created June 2, 2012 09:16
Ajaxified comment form
(function ($) {
$.ajaxSetup({
beforeSend: function(xhr, settings) {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
@markvl
markvl / models.py
Created June 2, 2012 09:06
Extract of models.py where I try to detect spam using Akismet and send mail after a comment has been posted
class BlogEntry(models.Model):
...
def comments_need_moderation(self):
"""Return whether comments need moderation or not."""
if (datetime.now() - self.publication_date >
timedelta(settings.MODERATION_DELTA)):
return True
return False
@markvl
markvl / setuphandlers.py
Created May 21, 2012 19:47
Install the initial profile (automatically) just once.
from Products.CMFCore.utils import getToolByName
INITIAL_PROFILE_ID = 'profile-foo.bar:initial'
def import_various(context):
"""Import step for configuration that is not handled in xml files.
"""
# Only run step if a flag file is present
if context.readDataFile('foo.bar_various.txt') is None:
return