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 / postgres_queries_and_commands.sql
Created April 14, 2020 10:37 — forked from rgreenjr/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%'
@gollum23
gollum23 / package.json
Created November 12, 2018 15:27 — forked from mburakerman/package.json
Webpack 4 config.js (Stylus to CSS and Babel) 👌 The Simplest Usage 👌
{
"name": "webpack-stylus",
"version": "1.0.0",
"scripts": {
"start": "webpack-dev-server --open --mode development",
"build": "webpack -p"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
@gollum23
gollum23 / exercise.tour.go
Created August 8, 2017 02:53 — forked from zyxar/exercise.tour.go
tour.golang exercise solutions
/* Exercise: Loops and Functions #43 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(2.)
@gollum23
gollum23 / gist:a0a1efed8547c06285fa0f4310a83cf4
Created July 19, 2017 11:12 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@gollum23
gollum23 / index.html
Created January 23, 2017 01:44 — forked from CodeMyUI/index.html
Pokemon Slider
<div class="slider__warpper">
<div class="flex__container flex--pikachu flex--active" data-slide="1">
<div class="flex__item flex__item--left">
<div class="flex__content">
<p class="text--sub">Pokemon Gen I</p>
<h1 class="text--big">Pikachu</h1>
<p class="text--normal">Pikachu is an Electric-type Pokémon introduced in Generation I. Pikachu are small, chubby, and incredibly cute mouse-like Pokémon. They are almost completely covered by yellow fur.</p>
</div>
<p class="text__background">Pikachu</p>
</div>
@gollum23
gollum23 / jupyter_shortcuts.md
Created November 8, 2016 22:19 — forked from kidpixo/jupyter_shortcuts.md
Keyboard shortcuts for ipython notebook 3.1.0 / jupyter

Toc

Keyboard shortcuts

The IPython Notebook has two different keyboard input modes. Edit mode allows you to type code/text into a cell and is indicated by a green cell border. Command mode binds the keyboard to notebook level actions and is indicated by a grey cell border.

MacOS modifier keys:

  • ⌘ : Command
@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)
# -*- 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`
@gollum23
gollum23 / .gitconfig
Last active August 29, 2015 14:14 — forked from pksunkara/config
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com