Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Kleber Soares klebercode

🎯
Focusing
View GitHub Profile
View Clone Schema (Postgres)
CREATE OR REPLACE FUNCTION public.clone_schema(
source_schema text,
dest_schema text)
RETURNS void AS
$BODY$
DECLARE
object text;
buffer text;
default_ text;
column_ text;
@klebercode
klebercode / custom-validation-inlineformset.py
Created Feb 4, 2020 — forked from nspo/custom-validation-inlineformset.py
Custom validation of Django inline formset
View custom-validation-inlineformset.py
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():
continue
@klebercode
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/manage.py run_gunicorn -b "0.0.0.0:$PORT" -w 3 --settings=settings.prod
@klebercode
klebercode / pipenv_jupyter.sh
Last active Jan 7, 2020 — forked from jhuangtw-dev/pipenv_jupyter.sh
Running Jupyter with pipenv
View pipenv_jupyter.sh
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
klebercode / 00_GraphQL_Subscriptions.md
Created Sep 23, 2019 — forked from tricoder42/00_GraphQL_Subscriptions.md
GraphQL Subscriptions with django-channels
View 00_GraphQL_Subscriptions.md

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

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

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

View jquery-scroll-animate.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Stackoverflow help please</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('html, body').animate({
View base.html
{% load static %}
<!DOCTYPE html>
<html lang="pt">
<head>
<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.