Skip to content

Instantly share code, notes, and snippets.

@lmann4
lmann4 / show_db_queries.py
Last active September 25, 2024 16:47
A utilitiy for adding printing and debugging queries.
import inspect
import logging
import shutil
import sys
from time import time
from types import MethodType
from typing import Optional
from django.conf import settings
from django.db import DEFAULT_DB_ALIAS, connections
@bmispelon
bmispelon / update.py
Created March 2, 2021 09:53
[Django ORM] Updating a JSONField based on the value of another field
"""
How to update JSONField based on the value of another field.
For example:
class MyModel(models.Model):
name = models.CharField(...)
data = models.JSONField()
How to update the MyModel table to store the `name` field inside the `data`
@apenab
apenab / javascript.json
Last active July 18, 2020 00:05
JavaScript (ES6) code snippets for Visual Studio Code
{
"reactFunctionalComponentWithPropTypes": {
"prefix": "rfc",
"body": [
"import React from \"react\";",
"import PropTypes from \"prop-types\";",
"",
"function ${1:${TM_FILENAME_BASE}}(props) {",
"\treturn (",
"\t\t<div>",
@okunishinishi
okunishinishi / Remove all git tags
Created March 8, 2014 03:12
Delete all git remote tags
#Delete local tags.
git tag -l | xargs git tag -d
#Fetch remote tags.
git fetch
#Delete remote tags.
git tag -l | xargs -n 1 git push --delete origin
#Delete local tasg.
git tag -l | xargs git tag -d