Skip to content

Instantly share code, notes, and snippets.

View gollum23's full-sized avatar
:octocat:
Learning all days

Diego Forero gollum23

:octocat:
Learning all days
View GitHub Profile
@gollum23
gollum23 / config
Created February 5, 2016 02:00
Config para cambiar la llave ssh
Host github.com
IdentityFile ~/.ssh/dev_rsa
@gollum23
gollum23 / superlog
Created February 3, 2016 02:52
Superlog Curso git platzi
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"
@gollum23
gollum23 / example.py
Created January 28, 2016 13:28
Ejemplo de formulario para personalizar con css
/* 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
@gollum23
gollum23 / papel_class.py
Last active January 26, 2016 16:16
Juego de Piedra papel, tijeras, lagarto, spock usando clases y verbos.
#!/usr/bin/env python
# -*-coding:utf-8-*-
from time import sleep
import random
class Element:
name = ''
win = []
win_verbs = []
lost = []
@gollum23
gollum23 / Papel.py
Created January 21, 2016 19:52
Juego de piedra papel o tijera con verbos
#!/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"]
@gollum23
gollum23 / copy_registers
Last active September 13, 2015 02:30 — forked from rg3915/copy_registers
Copiar registros de tabela OneToMany
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)
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
#!/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)
# -*- 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 ##
"""
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`