Skip to content

Instantly share code, notes, and snippets.

View klebercode's full-sized avatar
🎯
Focusing

Kleber Soares klebercode

🎯
Focusing
View GitHub Profile
@ivlevdenis
ivlevdenis / django_graphene_orderBy.py
Last active September 14, 2023 17:58
Django graphene orderBy
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
@vinicius73
vinicius73 / post.md
Created November 22, 2016 12:26
["LÓGICA DE PROGRAMAÇÃO" É BOBAGEM, e explicarei porquê.]

#["LÓGICA DE PROGRAMAÇÃO" É BOBAGEM, e explicarei porquê.]

Se preparem que o texto é longo.

Várias vezes chegam novatos aqui perguntando como começar, e a galera diz "estuda lógica primeiro, depois vai pra linguagem X". Vivo dizendo que é bobagem. Ontem, em particular, falei isso, e vieram várias pessoas por inbox me perguntar porquê (e uma pra me xingar, achando que falei por arrogância).

Pra facilitar, eu vou escrever uma boa explicação de porquê "lógica de programação" é furada, doa a quem doer, e postar na APDA e no fórum da EnergyLabs (para futuras referências, porque esse assunto vai voltar, ctz).

@freewayz
freewayz / django_model_deletable.py
Created September 27, 2016 14:43
Django check if model has related object before Deleting the model
#After looking for a way to check if a model instance can be deleted in django ,
#i came across many sample, but was not working as expected. Hope this solution can help.
#Let start by creating an Abstract model class which can be inherited by other model
class ModelIsDeletable(models.Model):
name = models.CharField(max_length=200, blank=True, null=True, unique=True)
description = models.CharField(max_length=200, blank=True, null=True)
date_modified = models.DateTimeField(auto_now_add=True)
@Manduro
Manduro / keyboard-attach.directive.ts
Last active August 24, 2020 06:50
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
@zbyte64
zbyte64 / async_app.py
Created May 26, 2016 20:47
Asyncio Views With Django
import asyncio
from django import http
from django.core.urlresolvers import set_script_prefix
from django.utils.encoding import force_str
from django.core.handlers.wsgi import get_script_name
from django_wsgi.handler import DjangoApplication
import logging
import logging
import sys
@fer-ri
fer-ri / background-image.ts
Created May 24, 2016 06:33
Background Image Style Directive for Angular 2 and Ionic 2
import {Directive, ElementRef, Input} from '@angular/core';
@Directive({
selector: '[background-image]'
})
export class BackgroundImage {
private el: HTMLElement;
constructor(el: ElementRef) {
this.el = el.nativeElement;
@alexgleason
alexgleason / m2m.py
Last active May 9, 2023 17:49
Many to many relationships in Wagtail
from django.db import models
from wagtail.wagtailsnippets.models import register_snippet
from wagtail.wagtailcore.models import Page
from modelcluster.fields import ParentalKey
from wagtail.wagtailadmin.edit_handlers import InlinePanel
@register_snippet
class Category(models.Model):
@EtienneR
EtienneR / user.js
Created January 7, 2016 23:39
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);
@aalvesjr
aalvesjr / tmux-atalhos.md
Last active January 30, 2023 22:44
[TMUX] Atalhos

quando ler <Prefix> será o padrão Ctrl + b

Window

  • <Prefix> c => para criar uma nova 'window'
  • <Prefix> % => para dividir uma 'window' verticalmente
  • <Prefix> " => para dividir uma 'window' horizontalmente
  • <Prefix> & => para fechar uma 'window'
  • <Prefix> . => move a window para algum indice ainda não utilizado
  • <Prefix> 0 a 9 => abre a 'window' com o numero digitado
  • \ w => abre a 'window' a partir de uma lista
@davidsan
davidsan / instagram.html
Last active October 5, 2017 07:59
Example of JSONP callback on Instagram Search API
<html>
<body>
<button id="btn" type="button">Search for jessicaalba on Instagram using JSONP</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/json2/20140204/json2.min.js"></script>
<script src="instagram.js"></script>
</body>
</html>