Skip to content

Instantly share code, notes, and snippets.

from .layout import FormHelper, FormHelperMixin
class MyForm(FormHelperMixin, forms.ModelForm):
class FormHelperMeta:
# works like Meta, we just use to store property overrides
# doesn't need to inherit
# helper_class = MyCustomHelper
submit_text = "Submit!"
action = reverse('account:login')
@danjac
danjac / crispy-form.py
Last active June 23, 2017 16:07
Django crispy form example
from django import forms
from django.contrib.localflavor.gb.forms import GBPostcodeField
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Fieldset, Submit
from crispy_forms.bootstrap import FormActions
from .models import Signup
input:not(.urlbar-input):not(.textbox-input):not(.form-control):not([type='checkbox']) {
-moz-appearance: none !important;
background-color: inherit;
color: inherit;
}
#downloads-indicator-counter {
color: white;
}
"""
Breadth-first search maze runner
maze_runner.py path-to-maze-file
Make sure your map has an entrance and exit on left & right side
respectively.
EXAMPLE:
###########
"""
https://en.wikipedia.org/wiki/Breadth-first_search
"""
import queue
def bfs(graph, root):
q = queue.Queue()
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
/*
* Copyright Simon Lydell 2015, 2016.
*
* This file is part of VimFx.
*
* VimFx is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
@danjac
danjac / defender.html
Last active April 4, 2016 16:11
Defender test
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://code.jquery.com/jquery-2.2.2.min.js"></script>
</head>
<body>
defmodule Fizzbuzz do
def run do
Enum.each(1..100, fn(num) -> IO.puts(get_message(num)) end)
end
def get_message(num) do
cond do
rem(num, 15) == 0 -> "fizzbuzz"
rem(num, 5) == 0 -> "buzz"
@danjac
danjac / adwaita.vimp
Created September 4, 2015 16:46
adwaita vimperator theme
hi Normal background: #e9e9e9; color:#215d9c;
hi CmdLine background: #e9e9e9; color:#215d9c;
hi CompGroup background: #e9e9e9; color:#215d9c;
hi CompTitle background: #dedede; font-weight: bold;
hi CompTitle>* color: #2e3436; padding: 1px 0.5ex; border-bottom: 2px solid #215d9c;border-top: 0.5px solid #d8d8d8;
hi CompItem background:#e9e9e9; color:#215d9c;
hi CompItem[selected] color: #ededed; background: #777;
hi CompDesc width: 500px; max-width: 500px; color: #465457;
hi CompDesc[selected] width: 500px; max-width: 500px; color: #ededed;
hi CompMsg margin-left: 16px; color: #215d9c;
package main
import (
"net/http"
"net/http/httputil"
"net/url"
)
func main() {