Skip to content

Instantly share code, notes, and snippets.

View jhillacre's full-sized avatar
🏗️

Joel Hillacre jhillacre

🏗️
View GitHub Profile
<script setup>
import { reactive } from "vue";
const updateState = reactive({
formValues: {},
formErrors: [],
fieldErrors: {},
});
const getFakeId = (array) => {
@jhillacre
jhillacre / TipTap.vue
Last active June 14, 2022 20:33
TipTap Vue 3 starter component using script setup
<template>
<div>
<editor-content :editor="editor" />
</div>
</template>
<script setup>
import { EditorContent, useEditor } from "@tiptap/vue-3";
import StarterKit from "@tiptap/starter-kit";
import { toRef, unref, watch } from "vue";
import logging
import typing
from traceback import format_exception
from traceback import format_exception_only
logger = logging.getLogger(__name__)
class NiceConsumerMixin:
async def receive_json(self, content: typing.Dict, **kwargs):
"""
// this ia snippit from a factory that makes vuex actions with. we make a module per stream.
// these are vueX actions, mutations and state are implied.
async subscribeActivity(context) {
context.commit("setActivitySubscriptionCount");
if (context.state.activitySubscriptions.count === 1) {
const listPromise = context.dispatch("list", { args: {} });
const subscribePromise = dcrfClient.subscribe(
stream,
{},
async (data, action) => {
from channels.db import database_sync_to_async
from djangochannelsrestframework.decorators import action as dcrf_action
from djangochannelsrestframework.generics import GenericAsyncAPIConsumer
from djangochannelsrestframework.mixins import CreateModelMixin
from djangochannelsrestframework.mixins import DeleteModelMixin
from djangochannelsrestframework.mixins import ListModelMixin
from djangochannelsrestframework.mixins import PaginatedModelListMixin
from djangochannelsrestframework.mixins import PatchModelMixin
from djangochannelsrestframework.mixins import UpdateModelMixin
from djangochannelsrestframework.observer import ModelObserver
@jhillacre
jhillacre / optimizemigration.py
Last active August 18, 2021 07:45
Rewrite manually optimized squash migrations.
# BSD 3-Clause License
#
# Copyright (c) 2017, Emergence by Design Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
from datetime import datetime
from operator import itemgetter
files = [
{
filename: '1.file',
mtime: datetime.now()
},
{
filename: '2.file',