Skip to content

Instantly share code, notes, and snippets.

Avatar

Curtis Maloney funkybob

View GitHub Profile
View MyTodo.html
<svelte:options tag="my-todo" />
<h1>Todos Svelte</h1>
<section>
<TodoInput on:add={addTodo}></TodoInput>
<ul id="list-container">
{#each items as item, index (item.id)}
<TodoItem
bind:checked={item.checked}
bind:text={item.text}
View Dockerfile
FROM python/3.7
# Install system dev packages
RUN apt update -y && \
apt install -y libmariadbclient-dev gcc
# Build wheels of all our requirements
COPY requirements/requirements.txt requirements/requirements.txt
RUN mkdir wheels/ && \
pip install -U pip && \
View gist:5bceb85ddef4db3fe2bebbc69c69829a
A gilbert project is a directory with 5 sub directories:
- static/
- pages/
- content/
- templates/
- dest/
Upon calling render, the site will:
- create an index of files in static; only referenced files will be copied to the destination
View parse.py
from __future__ import absolute_import
from uuid import uuid4
import parse
from django.urls.resolvers import RegexURLPattern, RegexURLResolver, ResolverMatch
def parse_uuid(text):
return uuid4(text)
View router.js
(function () {
function Router() {
EventTarget.call(this);
this.rules = [];
window.addEventListener('hashchange', this.hashChange.bind(this));
window.addEventListener('popstate', this.hashChange.bind(this));
}
Router.prototype = Object.create(EventTarget);
Router.prototype.constructor = Router;
View test.py
setup = '''
class prop:
def __init__(self, getter):
self.getter = getter
def __get__(self, instance, owner=None):
if instance is None:
return self
value = instance.__dict__[self.getter.__name__] = self.getter(instance)
View middleware_fileserve.py
import re
from gzip import GzipFile
from django.http import FileResponse
# TODO:
# - extra headers
# - expiration
@funkybob
funkybob / gist:6332718
Created Aug 25, 2013
My Vigenere ciper for CSRF
View gist:6332718
# If this were split out of the get_random_string def we
# we wouldn't need to repeat it here...
VALID_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
def mangle(token):
mask = get_random_string(len(token))
value = ''.join([
VALID_CHARS[ (VALID_CHARS.index(x) + VALID_CHARS.index(y)) % len(VALID_CHARS) ]
for x, y in zip(token, mask)
View admin.py
from django.contrib import admin
from django import forms
from .models import *
class ThroughInline(admin.TabularInline):
model = Through
raw_id_fields = ('unter',)
sortable_field_name = 'order'
formfield_overrides = {
You can’t perform that action at this time.