Skip to content

Instantly share code, notes, and snippets.

View emoss08's full-sized avatar
🖥️
Coding.... Per usual

Eric Moss emoss08

🖥️
Coding.... Per usual
View GitHub Profile
@emoss08
emoss08 / store.go
Last active March 24, 2024 05:35
Ent(Golang Entity Framework): Gorilla Session Store
package session
import (
"context"
"encoding/base32"
"errors"
"log"
"net/http"
"strings"
"time"
@emoss08
emoss08 / text_choices_to_const.py
Last active September 8, 2023 01:23
Converts models.TextChoices to Typescript Const
"""
Converts Models.TextChoices to TypeScript Const.
Primarily used for Select Fields
Example:
Input:
class JobFunctionChoices(models.TextChoices):
MANAGER = "MANAGER", _("Manager")
@emoss08
emoss08 / models_to_type.py
Last active February 25, 2024 23:48
Convert Django Models to Typescript Types
"""
Converts Django models to TypeScript types.
Example:
Input:
class JobTitle(GenericModel):
name = models.CharField(
_("Name"),
max_length=100,
  1. Run the following command to create a kubectlproxy service file.
sudo nano /lib/systemd/system/kubectlproxy.service
  1. Copy these contents into your file and save.
[Unit]
class ClogGenericAPIView(viewsets.ViewSet):
"""
Generic API View for CLOG use this class for any redundant logic.
"""
model = None
serializer = None
def list(self, request):
queryset = self.model.objects.all() # Or you could do a selector instead of model
serializer = self.serializer(queryset, many=True)
from django.utils.translation import gettext_lazy as _ # Import this bad boy
class Organization(TimeStampedModel):
"""
Organization Model Fields
"""
import time
def main():
"""Print the latest tutorial from Real Python"""
tic = time.perf_counter()
# code here
toc = time.perf_counter()
# Prints SQL statements to console. Put this in your settings.py
LOGGING = {
'version': 1,
'filters': {
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
}
},
'handlers': {
async function getChargeType(charge_id) {
// Charge Type API GET request
let url = "/api/charge_types/" + charge_id + "/";
// Await the response of the fetch call
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Token ' + window.localStorage.getItem('token'),
# Core Django Imports
from django.db.models.base import ModelBase
from django.contrib.auth import get_user_model
from django.contrib.auth.backends import BaseBackend
from django.contrib.auth.base_user import AbstractBaseUser
# Monta Imports
from monta_user.models import MontaUser