The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.
# pulling one User object
user = User.query.get(1)
#!/usr/bin/env bash | |
# set your own root folders, all children folders will become options for in sessionizer menu | |
root_folders="$HOME/projects $HOME/work $HOME/.config" | |
function attach_session() { | |
local session_root=$1 | |
local session_name=$(basename "$session_root" | tr . _) | |
cd $session_root | |
zellij attach --create $session_name |
The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.
# pulling one User object
user = User.query.get(1)
from django.db import ProgrammingError, models | |
from django.db.models.constants import LOOKUP_SEP | |
from django.db.models.query import normalize_prefetch_lookups | |
from rest_framework import serializers | |
from rest_framework.utils import model_meta | |
class OptimizeModelViewSetMetaclass(type): | |
""" | |
This metaclass optimizes the REST API view queryset using `prefetch_related` and `select_related` | |
if the `serializer_class` is an instance of `serializers.ModelSerializer`. |
I hereby claim:
To claim this, I am signing this object:
{ | |
'dates': { | |
3: { | |
'color': { | |
'main': u '#2B2B4A', | |
'primary': u '#5B4C7E', | |
'secondary': u '#DCCCFF' | |
}, | |
'date': datetime.date(2018, 11, 4), | |
'theme': u 'Python', |
Object.keys(object).filter(function (key) { | |
return key != "key"; | |
}).reduce(function(obj, key) { | |
obj[key] = object[key]; | |
return obj; | |
}, {}); |
#include <stdio.h> | |
float medescolar(float n1, float n2, float n3, float n4) { | |
// Cria variável que irá conter o valor da média | |
float media = 0; | |
// Cáculo simples da média: soma-se as notas e divide-se pela quantidade | |
// de notas | |
media = (n1 + n2 + n3 + n4) / 4; | |
return media; |
# old | |
@login_required | |
def undo_enrollment(request, slug): | |
course = get_object_or_404(Course, slug=slug) | |
enrollment = get_object_or_404( | |
Enrollment, | |
user=request.user, | |
course=course | |
) | |
if request.method == 'POST': |