Skip to content

Instantly share code, notes, and snippets.

View elliasmatheus's full-sized avatar
🏠
Working from home

Ellias Matheus elliasmatheus

🏠
Working from home
View GitHub Profile
@elliasmatheus
elliasmatheus / RenewExpiredGPGkey.md
Created April 30, 2024 21:28 — forked from TheSherlockHomie/RenewExpiredGPGkey.md
Updating expired GPG keys and backing them up 🔑🔐💻

Updating expired GPG keys and their backup 🔑🔐💻

I use a GPG key to sign my git commits.

An error like this one might be a sign of an expired GPG key.

error: gpg failed to sign the data fatal: failed to write commit object
@elliasmatheus
elliasmatheus / sqlparse.py
Created April 2, 2024 19:27 — forked from julen/sqlparse.py
Printing human-readable SQL queries to the console in scenarios where the django-debug-toolbar isn't available.
import sqlparse
qs = MyObject.objects.filter(foo='bar', baz__startswith='baz')
sql, params = qs.query.sql_with_params()
print sqlparse.format(str(sql % params),
reindent=True, keyword_case='upper')
@elliasmatheus
elliasmatheus / react-query-lite.js
Created March 11, 2024 17:45 — forked from nikasepiskveradze/react-query-lite.js
Lightweight implementation of React Query
import React from "react";
const context = React.createContext();
export function QueryClientProvider({ children, client }) {
React.useEffect(() => {
const onFocus = () => {
client.queries.forEach((query) => {
query.subscribers.forEach((subscriber) => {
subscriber.fetch();
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
args: ['--maxkb=500']
- id: fix-byte-order-marker
- id: check-case-conflict
# Use bash syntax
SHELL := /bin/bash
ARG := $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))
TARGETS_WITH_ARGS = help
.PHONY: TARGETS_WITH_ARGS
.DEFAULT_GOAL := help
## -- Help --
@elliasmatheus
elliasmatheus / 0fixup.md
Created January 31, 2024 16:27 — forked from silent1mezzo/0fixup.md
On undoing, fixing, or removing commits in git

A git choose-your-own-adventure!

This document is an attempt to be a fairly comprehensive guide to recovering from what you did not mean to do when using git. It isn't that git is so complicated that you need a large document to take care or your particular problem, it is more that the set of things that you might have done is so large that different techniques are needed depending on exactly what you have done and what you want to have happen.

@elliasmatheus
elliasmatheus / webdev_online_resources.md
Created December 11, 2023 22:59 — forked from bradtraversy/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
@elliasmatheus
elliasmatheus / one_session_per_user.middleware.py
Created May 8, 2023 17:10 — forked from peterdemin/one_session_per_user.middleware.py
django middleware that disallows concurent user login while allowing such for administrators
from one_session_per_user.models import User, Visitor
from django.contrib.sessions.models import Session
class OneSessionPerUserMiddleware(object):
"""http://stackoverflow.com/a/1814797"""
def process_request(self, request):
if isinstance(request.user, User):
current_key = request.session.session_key
@elliasmatheus
elliasmatheus / postgres_queries_and_commands.sql
Created April 12, 2023 16:42 — forked from abdulktx1/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'