Skip to content

Instantly share code, notes, and snippets.

View klebercode's full-sized avatar
🚴
Go...

Kleber Soares klebercode

🚴
Go...
View GitHub Profile
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      [email protected]:xxx/xxx.git  (fetch)
origin      [email protected]: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 / 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
@klebercode
klebercode / index.html
Created March 20, 2018 03:23 — forked from mottaquikarim/index.html
firebase storage / with upload of file to Firebase Storage itself
<!DOCTYPE html>
<html>
<head></head>
<body>
<input type="file" class="js-fileElem" multiple accept="image/*" style="display:none">
<a href="#" class="js-fileSelect">Select some files</a>
<script src="https://www.gstatic.com/firebasejs/3.8.0/firebase.js"></script>
@klebercode
klebercode / FileUploader.vue
Created March 20, 2018 03:23 — forked from CristalT/FileUploader.vue
File Uploader Component for Vue.js using Firebase Storage
<template>
<div>
<input type="file" multiple accept="image/*" @change="detectFiles($event.target.files)">
<div class="progress-bar" :style="{ width: progressUpload + '%'}">{{ progressUpload }}%</div>
</div>
</template>
<script>
@klebercode
klebercode / app.ts
Created February 22, 2018 18:15 — forked from EvanWillms/app.ts
Allow Ionic2 keyboard to open without pushing or scrolling content
// Minimum viable app.ts pulled from https://github.com/driftyco/ionic2-starter-blank/tree/41b4da8329636a95ab05d2579efd3a1527d2e830
// This snapshot is likely [email protected] compatable
import 'es6-shim';
import {App, Platform} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {HomePage} from './pages/home/home';
@App({
template: '<ion-nav [root]="rootPage"></ion-nav>',
@klebercode
klebercode / app.ts
Created February 22, 2018 18:15 — forked from EvanWillms/app.ts
Allow Ionic2 keyboard to open without pushing or scrolling content
// Minimum viable app.ts pulled from https://github.com/driftyco/ionic2-starter-blank/tree/41b4da8329636a95ab05d2579efd3a1527d2e830
// This snapshot is likely [email protected] compatable
import 'es6-shim';
import {App, Platform} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {HomePage} from './pages/home/home';
@App({
template: '<ion-nav [root]="rootPage"></ion-nav>',