Skip to content

Instantly share code, notes, and snippets.

@jayhale
jayhale / 445_fiscal_calendar.view.lkml
Last active May 30, 2023 21:23
Looker 4/4/5 Calendar PDT implementation
view: fiscal_calendar {
# Calculates the 4/4/5 fiscal calendar for all dates 2010-2050
# Expected query duration <1 s
derived_table: {
interval_trigger: "720 hours"
indexes: ["calendar_date"]
sql:
select
calendar.date as calendar_date,
# vercel-django-example/requirements.txt
# https://github.com/jayhale/vercel-django-example/blob/main/requirements.txt#L1
Django==3.2
# vercel-django-example/vercel_app/settings.py
# https://github.com/jayhale/vercel-django-example/blob/main/vercel_app/settings.py#L28
# ...
ALLOWED_HOSTS = ['.vercel.app'] # Allow *.vercel.app
# ...
DATABASES = {} # Prevent Django from loading an adapter
// vercel-django-example/vercel.json
// https://github.com/jayhale/vercel-django-example/blob/main/vercel.json#L1
{
"builds": [{
"src": "vercel_app/wsgi.py",
"use": "@ardnt/vercel-python-wsgi",
"config": { "maxLambdaSize": "15mb" }
}],
"routes": [
# vercel-django-example/example/urls.py
# https://github.com/jayhale/vercel-django-example/blob/main/example/urls.py#L7
from django.urls import path
from example.views import index
urlpatterns = [
path('', index),
]
# vercel-django-example/example/views.py
# https://github.com/jayhale/vercel-django-example/blob/main/example/views.py#L6
from datetime import datetime
from django.http import HttpResponse
def index(request):
now = datetime.now()
html = f'''
<html>
# vercel-django-example/vercel_app/urls.py
# https://github.com/jayhale/vercel-django-example/blob/main/vercel_app/urls.py#L21
urlpatterns = [
# ...
path('', include('example.urls')),
]
# vercel-django-example/vercel_app/settings.py
# https://github.com/jayhale/vercel-django-example/blob/main/vercel_app/settings.py#L43
INSTALLED_APPS = [
# ...
'example',
]
@jayhale
jayhale / now.json
Created May 7, 2019 12:19
Django staticfiles on Zeit Now: now.json
{
"version": 2,
"name": "now-django-staticfiles",
"builds": [
{
"src": "now_build_staticfiles.sh",
"use": "@now/static-build",
"config": {
"distDir": "staticfiles_build"
}
@jayhale
jayhale / now_build_staticfiles.sh
Created May 7, 2019 12:07
Django staticfiles on Zeit Now: now_build_staticfiles.sh
# now_build_staticfiles.sh
# Install Python 3.6 since it is missing in the Now build environment
yum install -y https://centos6.iuscommunity.org/ius-release.rpm
yum install -y python36u
# Install pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.6 get-pip.py