Skip to content

Instantly share code, notes, and snippets.

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

Regis Santos rg3915

🏠
Working from home
View GitHub Profile
@rg3915
rg3915 / index.html
Created September 16, 2024 06:47 — forked from aaizemberg/index.html
xkcd font
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>xkcd font</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js"></script>
<style>
@font-face {
font-family: xkcd;
@rg3915
rg3915 / README.md
Last active January 13, 2024 04:27 — forked from vallahor/README.md
Given a txt file with a tree structure of directories/files generate a sh with necessary commands to generate that file tree

sh from txt contains tree structure of directories and files

How to create sh commands from txt file contains tree structure of directories and files?

This program convert tree structure of directories and files generate a sh with necessary commands to generate that file tree.

He read input.txt and convert to output.sh.

This is result:

@rg3915
rg3915 / middleware.py
Last active July 8, 2024 03:04 — forked from marlonmartins2/middleware.py
middleware PermissionRequiredMixin redirect
from django.utils.deprecation import MiddlewareMixin #verificar se já saiu na versão que utiliza do django ou como ficou no update.
class RequestMiddleware(MiddlewareMixin):
"""
The middleware that intercept a request.
:param MiddlewareMixin: the mixin.
:type MiddlewareMixin: MiddlewareMixin
"""
@rg3915
rg3915 / table-emmet
Created December 19, 2022 03:43 — forked from anthanh/table-emmet
Emmet table example
table[name="pepe"]>thead>tr>th*3^^+tbody>tr*7>td{Basico}*3
@rg3915
rg3915 / apps.py
Created September 13, 2022 03:53 — forked from fleepgeek/apps.py
A Django Middleware to prevent multiple sessions for the same user. It automatically logs out the previous session and replaces it with the new session.
from django.apps import AppConfig
class ForumConfig(AppConfig):
name = 'forum'
# This function is the only new thing in this file
# it just imports the signal file when the app is ready
def ready(self):
import your_app_name.signals
@rg3915
rg3915 / build.py
Created February 15, 2022 22:41 — forked from guilhermecarvalhocarneiro/build.py
Código para automatizar a geração das urls, forms, templates, views e de um projeto DRF.
"""Esse manager é responsável por gerar os arquivos padrões de um projeto Django (templates, urls, views, forms)
baseado nas informações contidas na classe da App do projeto Django.
"""
import fileinput
import os
from pathlib import Path
from bs4 import BeautifulSoup
from core.management.commands.utils import Utils
@rg3915
rg3915 / Microsoft.PowerShell_profile.ps1
Created February 1, 2022 14:16
Aliases in Powershell
function gitpush{
git push -u origin master
}
Set-Alias gpu gitpush
function create_env {
python -m venv .venv
}
Set-Alias mkenv create_env
@rg3915
rg3915 / gist:e665b81fa56a2ba24dfd870a705b31be
Created December 19, 2021 01:34 — forked from toninhocajueiro/gist:086ae0f9dca7db0cebe2256507d26844
Função simples pra testar download de arquivo no DRF
# viewsets.py
from rest_framework.decorators import api_view, permission_classes
from django.http import FileResponse
from django.shortcuts import get_object_or_404
@api_view(['GET'])
@permission_classes((IsAuthenticated,))
def download(file):
@rg3915
rg3915 / make_gh_issue.py
Last active June 28, 2021 05:24
A simple Python script that can create an issue on a specific repository. github cli github issues
"""
requires the "PyGitHub" package (`pip install pygithub`).
You can leave out things like an assignee, a label etc., by simply leaving them out of the code.
"""
from github import Github
import os
from pprint import pprint

Tested only on Ubuntu 20.04, KDE Neon User Edition (based on Ubuntu 20.04) and OSX Mojave.

will probably work on other newer versions, with no changes, or with few changes in non-python dependencies (apt-get packages)

NOTE: Don't create a .sh file and run it all at once. It will not work. Copy, paste, and execute each command below manually. :-)

Ubuntu

# DO NOT RUN THIS AS A ROOT USER