Skip to content

Instantly share code, notes, and snippets.

View D2theR's full-sized avatar

Dan Rerko D2theR

View GitHub Profile
@rockavoldy
rockavoldy / 0-odoo-cheatsheet.md
Last active June 13, 2025 06:45
Odoo Cheatsheet
@jackton1
jackton1 / drf_optimize.py
Last active October 6, 2023 22:37
Optimize Django Rest Framework model views queries.
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`.
# example reading two serial devices using pyserial, asyncio and coroutines
import serial_asyncio
import asyncio
@asyncio.coroutine
def serial_read(device, **kwargs):
reader, writer = yield from serial_asyncio.open_serial_connection(url=device, **kwargs)
while True:
line = yield from reader.readline()
@kirkbushell
kirkbushell / Interceptor.js
Created January 7, 2016 22:41
Handling JWT, Vue JS and token refreshes
import Unauthorised from './Unauthorised'
export default function() {
return {
response: function(response) {
switch (response.status) {
case 401: return Unauthorised.handle();
}
return response;
@isccarrasco
isccarrasco / mdb2postgres.sh
Last active May 25, 2025 08:40 — forked from mutolisp/mdb2postgres.sh
Convert Microsoft Access *.mdb file into PostgreSQL database
#!/usr/bin/env bash
# install mdbtools first!
# mdbtools: https://github.com/brianb/mdbtools
# ref: https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL
DBMS=postgres
for MDB in `ls | grep .mdb$`
@mutolisp
mutolisp / mdb2postgres.sh
Created November 12, 2014 09:24
Convert Microsoft Access *.mdb file into PostgreSQL database
#!/usr/bin/env bash
# install mdbtools first!
# mdbtools: https://github.com/brianb/mdbtools
# ref: https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL
DBMS=postgres
for MDB in `ls | grep .mdb$`