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 / xclip.sh
Created January 19, 2016 23:33
xclip ssh id_rsa.pub
xclip -sel clip < ~/.ssh/id_rsa.pub
@rg3915
rg3915 / gen_random_datetime.py
Last active February 18, 2023 15:09
Generate Random Datetime Python
import random
from datetime import datetime, timedelta
min_year=1900
max_year=datetime.now().year
start = datetime(min_year, 1, 1, 00, 00, 00)
years = max_year - min_year+1
end = start + timedelta(days=365 * years)
@rg3915
rg3915 / group_by_day.md
Last active December 7, 2022 10:24
Some tests with date and datetime in Django aggregation, group by day and month, vencer n dias
@rg3915
rg3915 / graph_models.md
Last active February 20, 2024 07:39
Generate graphic model Django with PyGraphViz pygraphviz pydot generate model graph model 2020

How to generate graphic model Django with PyGraphViz?

sudo apt-get install -y graphviz libgraphviz-dev pkg-config
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install pygraphviz
pip uninstall pyparsing
pip install -Iv https://pypi.python.org/packages/source/p/pyparsing/pyparsing-1.5.7.tar.gz#md5=9be0fcdcc595199c646ab317c1d9a709
@rg3915
rg3915 / forms.py
Created February 29, 2016 05:33 — forked from neara/forms.py
Django Class Based Views and Inline Formset Example
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from models import Sponsor, Sponsorship
class SponsorForm(ModelForm):
class Meta:
model = Sponsor
@rg3915
rg3915 / boilerplate2.sh
Last active February 17, 2023 11:53
Boilerplate: Shell script to create a complete Django project in Mac with Python 3.7 and Django 2.2.12
# Shell script to create a complete Django project.
# This script require Python 3.x and pyenv
# Settings.py is config to Django 2.2.12
# The project contains:
# Settings config
# Person model and form
# Person list and detail
# Person create, update and delete
# Admin config
@rg3915
rg3915 / djangocms.sh
Last active March 2, 2016 19:45
Shell script to create a project to Django-CMS.
# Shell script to create a project to Django-CMS with Python 3.5
# Download:
# curl https://gist.githubusercontent.com/rg3915/15b2100f3eeba362ebd8/raw/27d1f1374f03e89bfc26648f08c35bc86eebc978/djangocms.sh -o djangocms.sh
# Usage:
# Type the following command, you can change the project name.
# source djangocms.sh
@rg3915
rg3915 / tree_.py
Created March 9, 2016 12:16
Transform list of urls in dict structured
urls = [
"/foo/",
"/foo/bar",
"/foo/bar/baz",
"/foo/bar/bez",
"/foo/bar/biz",
"/foo/ber",
"/foo/ber/baz",
"/foo/ber/bez",
"/foo/ber/biz",
@rg3915
rg3915 / tree.py
Last active March 17, 2018 02:06 — forked from lffsantos/tree.py
tree.py
from collections import defaultdict
import copy
import csv
import json
from urllib.parse import urlparse
def parser_urls(urls, orig={}):
'''
recebe uma lista de urls e vai parseando enquanto essa tiver um diretorio
@rg3915
rg3915 / setup.sh
Last active March 9, 2016 18:12 — forked from Benedikt1992/setup.sh
Setup apache-2.4.16 + php-5.6.11 on CentOS 6.7
#!/usr/bin/env bash
# Install dependencies
yum update -y
yum install -y gcc apr-devel apr-util-devel openssl-devel pcre-devel libxml2-devel libcurl-devel
mkdir setup && cd setup
wget wget https://olex-secure.openlogic.com/content/private/5e6a6f0815e830bba705e79e4a0470fbee8a5880//olex-secure.openlogic.com/httpd-2.4.16.tar.gz
tar -xvf httpd-2.4.16.tar.gz