Skip to content

Instantly share code, notes, and snippets.


Kleber Soares klebercode

View GitHub Profile
View Clone Schema (Postgres)
CREATE OR REPLACE FUNCTION public.clone_schema(
source_schema text,
dest_schema text)
object text;
buffer text;
default_ text;
column_ text;
klebercode /
Created Feb 4, 2020 — forked from nspo/
Custom validation of Django inline formset
class ProductAutochangeInlineFormSet(
forms.inlineformset_factory(ProductAutochangeSet, ProductAutochange, form=ProductAutochangeForm, extra=1)):
def clean(self):
super(ProductAutochangeInlineFormSet, self).clean()
product_pks = []
num_productautochanges = 0
for form in self.forms:
if not form.is_valid():
klebercode / newrelic-heroku.rst
Created Jan 9, 2020 — forked from pydanny/newrelic-heroku.rst
Getting New Relic onto a Heroku Django app
View newrelic-heroku.rst

Get the Python library:

pip install newrelic

Add this to your ProcFile:

web: newrelic-admin run-program python cn_project/ run_gunicorn -b "$PORT" -w 3
klebercode /
Last active Jan 7, 2020 — forked from jhuangtw-dev/
Running Jupyter with pipenv
pipenv install ipykernel jupyter
pipenv shell
python -m ipykernel install --user --name=$(basename $(pwd))
jupyter notebook
# then in UI, switch kernel to the one matching your pipenv shell name
klebercode /
Created Sep 23, 2019 — forked from tricoder42/
GraphQL Subscriptions with django-channels

GraphQL Subscription with django-channels

Django channels are official way for implementing async messaging in Django.

The primary caveat when working with GraphQL subscription is that we can't serialize message before broadcasting it to Group of subscribers. Each subscriber might use different GraphQL query so we don't know how to serialize instance in advance.

See related issue

remember_me = forms.BooleanField(required=False, widget=forms.CheckboxInput())
if not self.cleaned_data.get('remember_me'):
View tmux_cheatsheet.markdown

tmux cheatsheet

As configured in my dotfiles.

start new:


start new with session name:

View jquery-scroll-animate.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>Stackoverflow help please</title>
<script src=""></script>
$(document).ready(function() {
$('html, body').animate({
View base.html
{% load static %}
<!DOCTYPE html>
<html lang="pt">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Agenda de Contatos</title>
View style.css
.container-fluid {
margin: 3rem auto;
max-width: 62%;
/* Header */
header {
border-bottom: 1px solid gray;
margin-bottom: 3rem;
You can’t perform that action at this time.