This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Host github.com | |
IdentityFile ~/.ssh/dev_rsa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config --global alias.superlog "log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* models */ | |
from django.db import models | |
class Example(models.Model): | |
example = models.CharField(max_lenght=155, verbose_name="Ejemplo") | |
class Meta: | |
verbose_name = "Ejemplo" # Como se muestra en el administrador el modelo | |
verbose_name_plural = "Ejemplos" # Como se muestra en el administrador el modelo | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*-coding:utf-8-*- | |
from time import sleep | |
import random | |
class Element: | |
name = '' | |
win = [] | |
win_verbs = [] | |
lost = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*-coding:utf-8-*- | |
import time | |
from time import sleep | |
import random | |
sus="-"*35 | |
action = "" | |
win = True | |
depo=["piedra","papel","tijera", "lagarto", "spock"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from vendas_project.vendas.models import Sale, SaleDetail | |
s = Sale.objects.filter(pk=1) # filtra a Venda pelo pk | |
d = SaleDetail.objects.filter(sale=s) # filtra os itens dessa Venda | |
s = Sale.objects.get(pk=s) # com o get pega o pk da Venda que foi filtrada | |
s.pk = None | |
s.save() # salva uma cópia da Venda | |
for i in d: | |
n = SaleDetail.objects.create( | |
sale=s, product=i.product, quantity=i.quantity, price_sale=i.price_sale, subtotal=i.quantity * i.price_sale) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)" | |
PROMPT='${ret_status} %{$fg[cyan]%}%n%{$reset_color%}:%{$fg_bold[green]%}%c%{$reset_color%}$(git_super_status) %(!.#.$) ' | |
export __GIT_PROMPT_DIR=${0:A:h} | |
export GIT_PROMPT_EXECUTABLE=${GIT_PROMPT_USE_PYTHON:-"python"} | |
# Initialize colors. | |
autoload -U colors | |
colors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
# change this symbol to whatever you prefer | |
prehash = ':' | |
from subprocess import Popen, PIPE | |
import sys | |
gitsym = Popen(['git', 'symbolic-ref', 'HEAD'], stdout=PIPE, stderr=PIPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
###################################################################################################### | |
## ## | |
## SCRIPT EN PYTHON PARA EL RESPALDO DE BASES DE DATOS POSTGRES ## | |
## ## | |
## Almacenará tres tipos de copia: ## | |
## - Diarias: el sistema realizará una copia diaria por base de datos y eliminará aquellas ## | |
## que tengan más de N_DAYS_AGO_DIARY_BACKUP días de antiguedad ## | |
## - Semanales: el sistema realizará una copia semanal cada viernes de cada base de datos y ## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Two things are wrong with Django's default `SECRET_KEY` system: | |
1. It is not random but pseudo-random | |
2. It saves and displays the SECRET_KEY in `settings.py` | |
This snippet | |
1. uses `SystemRandom()` instead to generate a random key | |
2. saves a local `secret.txt` |