Skip to content

Instantly share code, notes, and snippets.

View klebercode's full-sized avatar
🎯
Focusing

Kleber Soares klebercode

🎯
Focusing
View GitHub Profile
#!/bin/bash
export GITHUB_REPO="user/repo"
export GITHUB_USERNAME=$(cat ~/.githubrc 2> /dev/null | grep user.login | cut -d ":" -f2 | xargs)
export GITHUB_PASSWORD=$(cat ~/.githubrc 2> /dev/null | grep user.password | cut -d ":" -f2 | xargs)
if [ -z "$GITHUB_USERNAME" ]
then
read -p "Type your Github username: " GITHUB_USERNAME
echo "user.login: $GITHUB_USERNAME" >> ~/.githubrc
fi
@klebercode
klebercode / actions.py
Created February 8, 2019 01:30 — forked from ahmontero/actions.py
Trace the changes made to a django model. You can see how to use it in example.py
# -*- encoding: utf-8 -*-
# --------------------------
# Ripped from django project
# --------------------------
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext as _
from django.utils.encoding import force_unicode
@klebercode
klebercode / iterm2-solarized.md
Created November 27, 2018 22:54 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

from graphene import relay, String, List
from graphene_django.filter import DjangoFilterConnectionField
from graphene_django.fields import DjangoConnectionField
from app.models import Model
class Object(DjangoObjectType):
class Meta:
model = Model
@klebercode
klebercode / 01_utils.py
Created September 28, 2018 17:25 — forked from mbrochh/01_utils.py
Using pagination with Django, graphene and Apollo
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
# First we create a little helper function, becase we will potentially have many PaginatedTypes
# and we will potentially want to turn many querysets into paginated results:
def get_paginator(qs, page_size, page, paginated_type, **kwargs):
p = Paginator(qs, page_size)
try:
page_obj = p.page(page)
except PageNotAnInteger:
@klebercode
klebercode / urls.py
Created September 27, 2018 00:04 — forked from duffn/urls.py
django-graphene JWT authorization
# Authorization with django-graphene
# using django-jwt-auth==0.0.2
from django.conf.urls import url
from django.views.decorators.csrf import csrf_exempt
from graphene_django.views import GraphQLView
from jwt_auth.mixins import JSONWebTokenAuthMixin
class AuthGraphQLView(JSONWebTokenAuthMixin, GraphQLView):
@klebercode
klebercode / upgrade.md
Created May 15, 2018 14:55 — forked from zulhfreelancer/upgrade.md
How to upgrade Heroku Postgres database plan?
  1. Assuming you have multiple Heroku apps and Git remote like so:
development https://git.heroku.com/xxx.git (fetch)
development https://git.heroku.com/xxx.git (push)
origin      git@bitbucket.org:xxx/xxx.git  (fetch)
origin      git@bitbucket.org:xxx/xxx.git  (push)
production  https://git.heroku.com/xxx.git (fetch)
production  https://git.heroku.com/xxx.git (push)
staging https://git.heroku.com/xxx.git (fetch)
@klebercode
klebercode / index.html
Created April 26, 2018 14:17
Vue.js Shopping Cart
<div class="main-wrapper">
<div class="header"><h1>Vue Shopping Cart</h1></div>
<div id="vue">
<cart :cart="cart" :cart-sub-total="cartSubTotal" :tax="tax" :cart-total="cartTotal" :checkout-bool="checkoutBool"></cart>
<products :cart="cart" :cart-sub-total="cartSubTotal" :tax="tax" :cart-total="cartTotal" :products-data="productsData"></products>
<checkout-area v-if="checkoutBool" :cart="cart" :tax="tax" :cart-sub-total="cartSubTotal" :cart-total="cartTotal" :products-data="productsData" :total-with-tax="totalWithTax"></checkout-area>
</div>
</div>
@klebercode
klebercode / home_page.dart
Created April 25, 2018 16:25 — forked from h4040/home_page.dart
NewsReader
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:url_launcher/url_launcher.dart';
import 'package:intl/intl.dart';
import 'dart:async';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:share/share.dart' as sharing;
import 'package:transparent_image/transparent_image.dart';
@klebercode
klebercode / keyboard-attach.directive.ts
Created March 25, 2018 20:48 — forked from Manduro/keyboard-attach.directive.ts
Ionic Keyboard Attach Directive
import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';
import { Keyboard } from '@ionic-native/keyboard';
import { Content, Platform } from 'ionic-angular';
import { Subscription } from 'rxjs/Subscription';
/**
* @name KeyboardAttachDirective
* @source https://gist.github.com/Manduro/bc121fd39f21558df2a952b39e907754
* @description