Skip to content

Instantly share code, notes, and snippets.

View mateuszpohl's full-sized avatar
⚔️

Mateusz Pohl mateuszpohl

⚔️
View GitHub Profile
@teserak
teserak / ctags_autocomplete.py
Created November 7, 2012 08:07 — forked from BlackMac/ctags_autocomplete.py
autocomplete over project for Sublime Text 2
# CTags based autocompletion plugin for Sublime Text 2
# You can add the file to the User Package in ~/Library/Application Support/Sublime Text 2/Packages and restart Sublime Text 2.
# generate the .tags file in your project root with "ctags -R -f .tags"
import sublime, sublime_plugin, os
class AutocompleteAll(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
tags_path = view.window().folders()[0]+"/.tags"
@teserak
teserak / gist:1675398
Created January 25, 2012 08:22 — forked from michelts/gist:1029336
FormsView
from django.views.generic.base import View, TemplateResponseMixin
from django.views.generic.edit import FormMixin, ProcessFormView
class MultipleFormsMixin(FormMixin):
"""
A mixin that provides a way to show and handle several forms in a
request.
"""
form_classes = {} # set the form classes as a mapping
@mdellavo
mdellavo / formencode-sqlalchemy.py
Created December 3, 2011 16:53
Formencode validators to validate the existence if records in a database
from formencode import validators, Schema
# FIXME - these are the new versions
class RecordExists(FancyValidator):
messages = {'not_found': 'No such record exists'}
def __init__(self, model, field=None, *args, **kwargs):
super(RecordExists, self).__init__(*args, **kwargs)
self.model = model
@sunilnandihalli
sunilnandihalli / curry.clj
Created December 17, 2010 20:33
a macro to create fixed-arity curryable function in clojure
(defmacro def-curry-fn [name args & body]
{:pre [(not-any? #{'&} args)]}
(if (empty? args)
`(defn ~name ~args ~@body)
(let [rec-funcs (reduce (fn [l v]
`(letfn [(helper#
([] helper#)
([x#] (let [~v x#] ~l))
([x# & rest#] (let [~v x#]
(apply (helper# x#) rest#))))]