@ -1,3 +1,5 @@
|
||||
# README # |
||||
|
||||
A bunch of my presentions, in [Reveal.js](http://lab.hakim.se/reveal-js/) format, most (if not all) in Portuguese. |
||||
|
||||
The canonical place for these presentations is [in my website](http://juliobiason.net/presentations/). |
||||
|
@ -0,0 +1 @@
|
||||
.hljs{display:block;padding:.5em;background:#f0f0f0}.hljs,.hljs-subst,.hljs-tag .hljs-title,.lisp .hljs-title,.clojure .hljs-built_in,.nginx .hljs-title{color:black}.hljs-string,.hljs-title,.hljs-constant,.hljs-parent,.hljs-tag .hljs-value,.hljs-rules .hljs-value,.hljs-rules .hljs-value .hljs-number,.hljs-preprocessor,.hljs-pragma,.haml .hljs-symbol,.ruby .hljs-symbol,.ruby .hljs-symbol .hljs-string,.hljs-aggregate,.hljs-template_tag,.django .hljs-variable,.smalltalk .hljs-class,.hljs-addition,.hljs-flow,.hljs-stream,.bash .hljs-variable,.apache .hljs-tag,.apache .hljs-cbracket,.tex .hljs-command,.tex .hljs-special,.erlang_repl .hljs-function_or_atom,.asciidoc .hljs-header,.markdown .hljs-header,.coffeescript .hljs-attribute{color:#800}.smartquote,.hljs-comment,.hljs-annotation,.hljs-template_comment,.diff .hljs-header,.hljs-chunk,.asciidoc .hljs-blockquote,.markdown .hljs-blockquote{color:#888}.hljs-number,.hljs-date,.hljs-regexp,.hljs-literal,.hljs-hexcolor,.smalltalk .hljs-symbol,.smalltalk .hljs-char,.go .hljs-constant,.hljs-change,.lasso .hljs-variable,.makefile .hljs-variable,.asciidoc .hljs-bullet,.markdown .hljs-bullet,.asciidoc .hljs-link_url,.markdown .hljs-link_url{color:#080}.hljs-label,.hljs-javadoc,.ruby .hljs-string,.hljs-decorator,.hljs-filter .hljs-argument,.hljs-localvars,.hljs-array,.hljs-attr_selector,.hljs-important,.hljs-pseudo,.hljs-pi,.haml .hljs-bullet,.hljs-doctype,.hljs-deletion,.hljs-envvar,.hljs-shebang,.apache .hljs-sqbracket,.nginx .hljs-built_in,.tex .hljs-formula,.erlang_repl .hljs-reserved,.hljs-prompt,.asciidoc .hljs-link_label,.markdown .hljs-link_label,.vhdl .hljs-attribute,.clojure .hljs-attribute,.asciidoc .hljs-attribute,.lasso .hljs-attribute,.coffeescript .hljs-property,.hljs-phony{color:#88F}.hljs-keyword,.hljs-id,.hljs-title,.hljs-built_in,.hljs-aggregate,.css .hljs-tag,.hljs-javadoctag,.hljs-phpdoc,.hljs-yardoctag,.smalltalk .hljs-class,.hljs-winutils,.bash .hljs-variable,.apache .hljs-tag,.go .hljs-typename,.tex .hljs-command,.asciidoc .hljs-strong,.markdown .hljs-strong,.hljs-request,.hljs-status{font-weight:bold}.asciidoc .hljs-emphasis,.markdown .hljs-emphasis{font-style:italic}.nginx .hljs-built_in{font-weight:normal}.coffeescript .javascript,.javascript .xml,.lasso .markup,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:.5} |
@ -0,0 +1,154 @@
|
||||
/** |
||||
* Obsidian style |
||||
* ported by Alexander Marenin (http://github.com/ioncreature) |
||||
*/ |
||||
|
||||
.hljs { |
||||
display: block; padding: 0.5em; |
||||
background: #282B2E; |
||||
} |
||||
|
||||
.hljs-keyword, |
||||
.hljs-literal, |
||||
.hljs-change, |
||||
.hljs-winutils, |
||||
.hljs-flow, |
||||
.lisp .hljs-title, |
||||
.clojure .hljs-built_in, |
||||
.nginx .hljs-title, |
||||
.css .hljs-id, |
||||
.tex .hljs-special { |
||||
color: #93C763; |
||||
} |
||||
|
||||
.hljs-number { |
||||
color: #FFCD22; |
||||
} |
||||
|
||||
.hljs { |
||||
color: #E0E2E4; |
||||
} |
||||
|
||||
.css .hljs-tag, |
||||
.css .hljs-pseudo { |
||||
color: #D0D2B5; |
||||
} |
||||
|
||||
.hljs-attribute, |
||||
.hljs .hljs-constant { |
||||
color: #668BB0; |
||||
} |
||||
|
||||
.xml .hljs-attribute { |
||||
color: #B3B689; |
||||
} |
||||
|
||||
.xml .hljs-tag .hljs-value { |
||||
color: #E8E2B7; |
||||
} |
||||
|
||||
.hljs-code, |
||||
.hljs-class .hljs-title, |
||||
.hljs-header { |
||||
color: white; |
||||
} |
||||
|
||||
.hljs-class, |
||||
.hljs-hexcolor { |
||||
color: #93C763; |
||||
} |
||||
|
||||
.hljs-regexp { |
||||
color: #D39745; |
||||
} |
||||
|
||||
.hljs-at_rule, |
||||
.hljs-at_rule .hljs-keyword { |
||||
color: #A082BD; |
||||
} |
||||
|
||||
.hljs-doctype { |
||||
color: #557182; |
||||
} |
||||
|
||||
.hljs-link_url, |
||||
.hljs-tag, |
||||
.hljs-tag .hljs-title, |
||||
.hljs-bullet, |
||||
.hljs-subst, |
||||
.hljs-emphasis, |
||||
.haskell .hljs-type, |
||||
.hljs-preprocessor, |
||||
.hljs-pragma, |
||||
.ruby .hljs-class .hljs-parent, |
||||
.hljs-built_in, |
||||
.sql .hljs-aggregate, |
||||
.django .hljs-template_tag, |
||||
.django .hljs-variable, |
||||
.smalltalk .hljs-class, |
||||
.hljs-javadoc, |
||||
.django .hljs-filter .hljs-argument, |
||||
.smalltalk .hljs-localvars, |
||||
.smalltalk .hljs-array, |
||||
.hljs-attr_selector, |
||||
.hljs-pseudo, |
||||
.hljs-addition, |
||||
.hljs-stream, |
||||
.hljs-envvar, |
||||
.apache .hljs-tag, |
||||
.apache .hljs-cbracket, |
||||
.tex .hljs-command, |
||||
.hljs-prompt { |
||||
color: #8CBBAD; |
||||
} |
||||
|
||||
.hljs-string { |
||||
color: #EC7600; |
||||
} |
||||
|
||||
.hljs-comment, |
||||
.java .hljs-annotation, |
||||
.hljs-blockquote, |
||||
.hljs-horizontal_rule, |
||||
.python .hljs-decorator, |
||||
.hljs-template_comment, |
||||
.hljs-pi, |
||||
.hljs-deletion, |
||||
.hljs-shebang, |
||||
.apache .hljs-sqbracket, |
||||
.tex .hljs-formula { |
||||
color: #818E96; |
||||
} |
||||
|
||||
.hljs-keyword, |
||||
.hljs-literal, |
||||
.css .hljs-id, |
||||
.hljs-phpdoc, |
||||
.hljs-title, |
||||
.hljs-header, |
||||
.haskell .hljs-type, |
||||
.vbscript .hljs-built_in, |
||||
.sql .hljs-aggregate, |
||||
.rsl .hljs-built_in, |
||||
.smalltalk .hljs-class, |
||||
.diff .hljs-header, |
||||
.hljs-chunk, |
||||
.hljs-winutils, |
||||
.bash .hljs-variable, |
||||
.apache .hljs-tag, |
||||
.tex .hljs-special, |
||||
.hljs-request, |
||||
.hljs-at_rule .hljs-keyword, |
||||
.hljs-status { |
||||
font-weight: bold; |
||||
} |
||||
|
||||
.coffeescript .javascript, |
||||
.javascript .xml, |
||||
.tex .hljs-formula, |
||||
.xml .javascript, |
||||
.xml .vbscript, |
||||
.xml .css, |
||||
.xml .hljs-cdata { |
||||
opacity: 0.5; |
||||
} |
After Width: | Height: | Size: 552 KiB |
After Width: | Height: | Size: 1.7 MiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 42 KiB |
@ -0,0 +1,374 @@
|
||||
<!doctype html> |
||||
<html lang="en"> |
||||
|
||||
<head> |
||||
<meta charset="utf-8"> |
||||
|
||||
<title>AJAX/SOSP/CORS/CSRF</title> |
||||
|
||||
<meta name="author" content="Julio Biason"> |
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" /> |
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> |
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> |
||||
|
||||
<link rel="stylesheet" href="_external/reveal.min.css"> |
||||
<link rel="stylesheet" href="_external/night.css" id="theme"> |
||||
|
||||
<!-- For syntax highlighting --> |
||||
<link rel="stylesheet" href="_external/zenburn.css"> |
||||
|
||||
<!-- If the query includes 'print-pdf', include the PDF print sheet --> |
||||
<script> |
||||
if( window.location.search.match( /print-pdf/gi ) ) { |
||||
var link = document.createElement( 'link' ); |
||||
link.rel = 'stylesheet'; |
||||
link.type = 'text/css'; |
||||
link.href = '_external/pdf.css'; |
||||
document.getElementsByTagName( 'head' )[0].appendChild( link ); |
||||
} |
||||
</script> |
||||
|
||||
<!--[if lt IE 9]> |
||||
<script src="reveal.js/lib/js/html5shiv.js"></script> |
||||
<![endif]--> |
||||
|
||||
<style> |
||||
.semi-opaque { |
||||
background-color: rgba(0, 0, 0, 0.7); |
||||
} |
||||
|
||||
* { |
||||
hyphens: none !important; |
||||
-moz-hyphens: none !important; |
||||
} |
||||
</style> |
||||
</head> |
||||
|
||||
<body> |
||||
|
||||
<div class="reveal"> |
||||
<!-- Any section element inside of this container is displayed as a slide --> |
||||
<div class="slides"> |
||||
<section data-background='_images/ajax-sosp-cors-csrf.png' class='semi-opaque'> |
||||
<h1>AJAX / SOSP / CORS / CSRF</h1> |
||||
|
||||
<p class='fragment'><small> |
||||
(Ou 4 siglas, 16 letras e uma dor de cabeça) |
||||
</small></p> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>Agenda</h2> |
||||
|
||||
<p>Mostrar como aplicações web ricas se comportam quando |
||||
o conteúdo está vindo de uma fonte que não a fonte original.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>A Idéia</h2> |
||||
|
||||
<p>Gerar uma view com conteúdo que será inserido em outro site; |
||||
o conteúdo deverá abrir um modal para pedir mais dados para o |
||||
usuário.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>Passo 1: O Conteúdo</h2> |
||||
|
||||
<p>Carregado por AJAX, com jQuery. Fácil.</p> |
||||
|
||||
<p><pre><code data-trim> |
||||
$(function() { |
||||
$("#div-especial").load("http://outrosite.com/conteudo.html"); |
||||
}); |
||||
</code></pre></p> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2>Problema 1: SOSP (Same Origin Security Policy)</h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Same Origin Security Policy é assegurado pelo browser, barrando |
||||
requisições vindas de lugares que não são o lugar original.</p> |
||||
|
||||
<p class='fragment'>"Lugar original" = URL requisitada |
||||
tem mesmo esquema (http vs https), mesmo domínio |
||||
(subdomínios não contam), mesma porta (ou implício |
||||
80) da URL que está fazendo a requisição.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Página em <code>http://outrosite.com/conteudo.html</code> pede:</p> |
||||
|
||||
<ul> |
||||
<li class='fragment'><code>http://outrosite.com/dados.json</code> ⇒ OK</li> |
||||
<li class='fragment'><code>http://outrosite.com/<strong>dir</strong>/dados.json</code> ⇒ OK</li> |
||||
<li class='fragment'><code>http://<strong>usuário:senha</strong>@outrosite.com/dir/dados.json</code> ⇒ OK</li> |
||||
<li class='fragment'><code>http://outrosite.com<strong>:8080</strong>/dados.json</code> ⇒ NOT!</li> |
||||
<li class='fragment'><code><strong>https</strong>://outrosite.com/dados.json</code> ⇒ NOT!</li> |
||||
<li class='fragment'><code>http://<strong>api.</strong>outrosite.com/dados.json</code> ⇒ NOT!</li> |
||||
<li class='fragment'><code>http://outrosite.com<strong>:80</strong>/dados.json</code> ⇒ talvez...</li> |
||||
</ul> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Apenas lembrando: isso é forçado pelo |
||||
<em>browser</em>, não pelo serviço.</p> |
||||
|
||||
<p>Outras aplicações podem passar por cima do Same |
||||
Origin se quiserem.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Restrições de subdomínios podem ser relaxadas se |
||||
scripts forem carregados de subdomínios |
||||
diferentes:</p> |
||||
|
||||
<p>Se a página em <code>http://outrosite.com/</code> |
||||
carregar um script de |
||||
<code>http://api.outrosite.com</code>, a restrição de |
||||
subdomínios pode ser removida para funções do |
||||
script.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Se não tiver como relaxar as restrições, utiliza-se |
||||
CORS.</p> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2>Problema 2: CORS (Cross-Origin Resource Sharing)</h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>CORS é implementado no servidor e diz se o serviço |
||||
pode ou não utilizar aquele recurso.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Browser rodando em <code>http://outrosite.com</code> |
||||
requisita serviço em |
||||
<code>http://api.outrosite.com/</code>.</p> |
||||
|
||||
<p>Para isso, envia o header <code>Origin</code>.</p> |
||||
|
||||
<p><pre><code data-trim> |
||||
Origin: http://outrosite.com |
||||
</code></pre></p> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Servidor olha o header, verifica se a URL tem permissão |
||||
para acessar os recursos, é retornado o header |
||||
<code>Access-Control-Allow-Origin</code>.</p> |
||||
|
||||
<p><pre><code data-trim> |
||||
Access-Control-Allow-Origin: http://outrosite.com |
||||
</code></pre></p> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>De novo, isso é controlado pelo <em>browser</em>; um |
||||
browser que não siga corretamente o controle de acesso ou um |
||||
aplicativo qualquer poderiam passar por cima dessa restrição |
||||
e continuar lendo o conteúdo.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<h3>Django-CORS-Headers</h3> |
||||
|
||||
<p>App para configurar CORS sozinho.</p> |
||||
|
||||
<p><pre><code data-trim> |
||||
CORS_ORIGIN_WHITELIST = ( |
||||
'outrosite.com', |
||||
) |
||||
</code></pre></p> |
||||
|
||||
<p>ou</p> |
||||
|
||||
<p><pre><code data-trim> |
||||
CORS_ORIGIN_REGEX_WHITELIST = ( |
||||
'^(https?://)?(\w+\.)?outrosite\.com$', |
||||
) |
||||
</code></pre></p> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Agora o site externo consegue carregar o conteúdo das |
||||
views.</p> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2>Problema 2.5: URLs reversas</h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Para resolver URLs, usamos a tag <code>{% url vew_id %}</code> |
||||
para retornar a URL da view.</p> |
||||
|
||||
<p>O problema é que é retornada a URL absoluta para a view, |
||||
sem considerar o domínio da view.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<p><pre><code data-trim> |
||||
<a href='/view/'> |
||||
</code></pre></p> |
||||
|
||||
<p>em <code>http://outrosite.com</code> vira |
||||
<code>http://outrosite.com/view/</code>.</p> |
||||
|
||||
<p>Mas se a view estiver num domínio diferente, o mesmo |
||||
não é considerado.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<ul> |
||||
<li>Se <code>http://outrosite.com</code> carregar o conteúdo |
||||
de <code>http://api.outrosite.com</code></li> |
||||
<li class='fragment'>... e <code>http://api.outrosite.com</code> tiver uma view |
||||
com URL absoluta <code>/view/</code></li> |
||||
<li class='fragment'>... o browser irá resolver como |
||||
<code>http://outrosite.com/view/</code></li> |
||||
<li class='fragment'>... quando deveria ser |
||||
<code>http://api.outrosite.com/view/</code>.</li> |
||||
</ul> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Solução: considerar que <code>SITE_URL</code> (do |
||||
<code>settings.py</code>) está correto e usar nas URLs.</p> |
||||
|
||||
<p><pre><code data-trim> |
||||
<a href='{{ settings.SITE_URL }}{% url "view_id" %}'> |
||||
</code></pre></p> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2>Problema 3: CSRF</h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Resumo:</p> |
||||
|
||||
<ul> |
||||
<li>"csrftoken" é gerado na sessão do usuário.</li> |
||||
<li>Campo "csrftoken" é adicionado no form.</li> |
||||
<li>Quando o form retorna no POST, é verificado se é o |
||||
mesmo indicado na sessão do usuário.</li> |
||||
</ul> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Problema: Informações do token é passada num cookie.</p> |
||||
|
||||
<p><pre><code> |
||||
Set-Cookie: "csrftoken=t5HBi8EbkPk340nnpkdb8qxQsy2n8LwY; |
||||
expires=Tue, 04-Aug-2015 16:40:38 GMT; Max-Age=31449600; Path=/" |
||||
</code></pre></p> |
||||
|
||||
<p>Cookies não são processados durante requisições AJAX.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Solução correta:</p> |
||||
|
||||
<p>Ao receber uma requisição AJAX, processar os headers também, |
||||
verificar a existência de "Set-Cookie", verificar se "csrftoken" |
||||
está na lista, guardar o valor e usar nas requisições seguintes.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>Solução utilizada:</p> |
||||
|
||||
<p><pre><code> |
||||
from django.views.decorators.csrf import csrf_exempt |
||||
|
||||
@csrf_exempt |
||||
def minha_view(request): |
||||
.... |
||||
</code></pre></p> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2>Problema 3.5: CSRF em Class Based Views</h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<p><pre><code> |
||||
class MinhaView(View): |
||||
@csrf_exempt |
||||
def post(self, request): |
||||
.... |
||||
</code></pre> </p> |
||||
|
||||
<p>... não funciona.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<p>É preciso aplicar decorators no dispatch da view:</p> |
||||
|
||||
<p><pre><code> |
||||
@csrf_exempt |
||||
def dispatch(self, *args, **kwargs): |
||||
u"""Altera o dispatch para dispensar CSRF (por cauxa do AJAX).""" |
||||
return super(MinhaView, self).dispatch(*args, **kwargs) |
||||
</code></pre></p> |
||||
</section> |
||||
</section> |
||||
|
||||
<section data-background='_images/thats-all-folks.jpg'> |
||||
<p></p> |
||||
</section> |
||||
|
||||
<section data-background='_images/thats-all-folks.jpg' class='semi-opaque'> |
||||
Dica: Evite ter objetos cortantes próximos quando estiver lidando |
||||
com AJAX/SOSP/CORS/CSRF. |
||||
</section> |
||||
</div> |
||||
</div> |
||||
|
||||
<script src="_external/head.min.js"></script> |
||||
<script src="_external/reveal.min.js"></script> |
||||
|
||||
<script> |
||||
|
||||
// Full list of configuration options available here: |
||||
// https://github.com/hakimel/reveal.js#configuration |
||||
Reveal.initialize({ |
||||
controls: true, |
||||
progress: true, |
||||
history: true, |
||||
center: true, |
||||
|
||||
theme: 'night', |
||||
transition: 'linear', |
||||
|
||||
// Optional libraries used to extend on reveal.js |
||||
dependencies: [ |
||||
{ src: '_external/classList.js', condition: function() { return !document.body.classList; } }, |
||||
{ src: '_external/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, |
||||
{ src: '_external/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, |
||||
{ src: '_external/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, |
||||
{ src: '_external/zoom.js', async: true, condition: function() { return !!document.body.classList; } }, |
||||
{ src: '_external/notes.js', async: true, condition: function() { return !!document.body.classList; } } |
||||
] |
||||
}); |
||||
|
||||
</script> |
||||
|
||||
</body> |
||||
</html> |
@ -0,0 +1,143 @@
|
||||
<!doctype html> |
||||
<html lang="en"> |
||||
|
||||
<head> |
||||
<meta charset="utf-8"> |
||||
|
||||
<title>Timetracking com Get Things GNOME + Hamster</title> |
||||
|
||||
<meta name="author" content="Julio Biason"> |
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" /> |
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> |
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> |
||||
|
||||
<link rel="stylesheet" href="_external/reveal.min.css"> |
||||
<link rel="stylesheet" href="_external/default.css" id="theme"> |
||||
|
||||
<!-- For syntax highlighting --> |
||||
<link rel="stylesheet" href="_external/zenburn.css"> |
||||
|
||||
<!-- If the query includes 'print-pdf', include the PDF print sheet --> |
||||
<script> |
||||
if( window.location.search.match( /print-pdf/gi ) ) { |
||||
var link = document.createElement( 'link' ); |
||||
link.rel = 'stylesheet'; |
||||
link.type = 'text/css'; |
||||
link.href = '_external/pdf.css'; |
||||
document.getElementsByTagName( 'head' )[0].appendChild( link ); |
||||
} |
||||
</script> |
||||
|
||||
<!--[if lt IE 9]> |
||||
<script src="reveal.js/lib/js/html5shiv.js"></script> |
||||
<![endif]--> |
||||
|
||||
<style> |
||||
.semi-opaque { |
||||
background-color: rgba(0, 0, 0, 0.7); |
||||
} |
||||
|
||||
* { |
||||
hyphens: none !important; |
||||
-moz-hyphens: none !important; |
||||
} |
||||
|
||||
img { |
||||
height: 400px; |
||||
} |
||||
</style> |
||||
</head> |
||||
|
||||
<body> |
||||
|
||||
<div class="reveal"> |
||||
<!-- Any section element inside of this container is displayed as a slide --> |
||||
<div class="slides"> |
||||
<section> |
||||
<h1>Timetracking com Get Things GNOME + Project Hamster</h1> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>O que é o que?</h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<h3>Get Things GNOME</h3> |
||||
|
||||
<img src='_images/gtg.png'> |
||||
|
||||
<p>Controle de coisas pra fazer (TODO).</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<h3>Get Things GNOME</h3> |
||||
|
||||
<img src='_images/gtg-plugins.png'> |
||||
|
||||
<p>Plugin para ativar a opção de "Star Task on Hamster".</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<h3>Project Hamster</h3> |
||||
|
||||
<img src='_images/hamster.png'> |
||||
|
||||
<p>Controle de tempo de tarefas (qualquer tarefa).</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<h3>Project Hamster</h3> |
||||
|
||||
<img src='_images/hamster-totals.png'> |
||||
|
||||
<p>Tempo total dispendido por tarefa.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<h3>Bônus para usuários GNOME 3:</h3> |
||||
|
||||
<img src='_images/hamster-extension.png'> |
||||
|
||||
<p>Extension para GNOME 3 em |
||||
<a href="http://extensions.gnome.org">Extensions.GNOME.ORG</a>.</p> |
||||
</section> |
||||
|
||||
<section data-background='_images/thats-all-folks.jpg'> |
||||
<section></section> |
||||
</section> |
||||
</div> |
||||
</div> |
||||
|
||||
<script src="_external/head.min.js"></script> |
||||
<script src="_external/reveal.min.js"></script> |
||||
|
||||
<script> |
||||
|
||||
// Full list of configuration options available here: |
||||
// https://github.com/hakimel/reveal.js#configuration |
||||
Reveal.initialize({ |
||||
controls: true, |
||||
progress: true, |
||||
history: true, |
||||
center: true, |
||||
|
||||
theme: 'default', |
||||
transition: 'linear', |
||||
|
||||
// Optional libraries used to extend on reveal.js |
||||
dependencies: [ |
||||
{ src: '_external/classList.js', condition: function() { return !document.body.classList; } }, |
||||
{ src: '_external/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, |
||||
{ src: '_external/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, |
||||
{ src: '_external/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, |
||||
{ src: '_external/zoom.js', async: true, condition: function() { return !!document.body.classList; } }, |
||||
{ src: '_external/notes.js', async: true, condition: function() { return !!document.body.classList; } } |
||||
] |
||||
}); |
||||
|
||||
</script> |
||||
|
||||
</body> |
||||
</html> |
@ -0,0 +1,407 @@
|
||||
<!doctype html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
|
||||
<title>Pylint, Warnings e Correções</title> |
||||
|
||||
<meta name="author" content="Julio Biason"> |
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" /> |
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> |
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> |
||||
|
||||
<link rel="stylesheet" href="_external/reveal.min.css"> |
||||
<link rel="stylesheet" href="_external/night.css" id="theme"> |
||||
|
||||
<!-- For syntax highlighting --> |
||||
<link rel="stylesheet" href="_external/zenburn.css"> |
||||
|
||||
<!-- If the query includes 'print-pdf', include the PDF print sheet --> |
||||
<script> |
||||
if( window.location.search.match( /print-pdf/gi ) ) { |
||||
var link = document.createElement( 'link' ); |
||||
link.rel = 'stylesheet'; |
||||
link.type = 'text/css'; |
||||
link.href = '_external/pdf.css'; |
||||
document.getElementsByTagName( 'head' )[0].appendChild( link ); |
||||
} |
||||
</script> |
||||
|
||||
<!--[if lt IE 9]> |
||||
<script src="reveal.js/lib/js/html5shiv.js"></script> |
||||
<![endif]--> |
||||
|
||||
<style> |
||||
.semi-opaque { |
||||
background-color: rgba(0, 0, 0, 0.7); |
||||
} |
||||
|
||||
* { |
||||
hyphens: none !important; |
||||
-moz-hyphens: none !important; |
||||
} |
||||
|
||||
div.code { |
||||
font-size: 150% |
||||
} |
||||
</style> |
||||
</head> |
||||
|
||||
<body> |
||||
<div class="reveal"> |
||||
<!-- Any section element inside of this container is displayed as a slide --> |
||||
<div class="slides"> |
||||
<section data-background='_images/pylint.png' class='semi-opaque'> |
||||
<h1>Pylint, Warnings e Correções</h1> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>missing-docstring</code></h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>O que é o erro</h2> |
||||
<div class='code'> |
||||
<p><pre><code data-trim class='python'> |
||||
def funcao(valor): |
||||
return valor * 2 |
||||
</code></pre></p> |
||||
</div> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>Solução</h2> |
||||
|
||||
<p>Documente suas funções!</p> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>wildcard-import</code></h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>O que é o erro</h2> |
||||
<div class='code'> |
||||
<p><pre><code data-trim class='python'> |
||||
from module import * |
||||
</code></pre></p> |
||||
</div> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>Solução</h2> |
||||
|
||||
<p>Importe apenas as funções módulos que são usados.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>Por que não usar "import *"</h2> |
||||
|
||||
<ul> |
||||
<li>O módulo pode ter código não protegido por |
||||
função, classe ou <code>if __name__ == '__main__'</code></li> |
||||
<li>Poluíção do namespace.</li> |
||||
<li>Módulo pode redefinir uma função presente no |
||||
módulo atual.</li> |
||||
</ul> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>unused-import</code></h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>O que é o erro</h2> |
||||
|
||||
<div class='code'> |
||||
<p><pre><code data-trim class='python'> |
||||
from module import function |
||||
</code></pre></p> |
||||
</div> |
||||
|
||||
<p>(E <code>function()</code> não é usado em lugar algum.)</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>Solução</h2> |
||||
|
||||
<p>Remova o import.</p> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>Dica!</h2> |
||||
|
||||
<p>Quebrar imports em várias linhas facilita correção desse |
||||
tipo de problema.</p> |
||||
|
||||
<div class='code'> |
||||
<p><pre><code data-trim class='python'> |
||||
from module import func1 |
||||
from module import func2 |
||||
</pre></code></p> |
||||
</div> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>unused-argument</code></h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>O que é o erro</h2> |
||||
|
||||
<div class='code'> |
||||
<p><pre><code data-trim> |
||||
def func(arg1, arg2): |
||||
return arg1 * 2 |
||||
</pre></code></p> |
||||
</div> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>Solução</h2> |
||||
|
||||
<ul> |
||||
<li>Remova o parâmetro desnecessário</li> |
||||
<li>Altere o parâmetro para "_"</li> |
||||
</ul> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>Corner case</h2> |
||||
|
||||
<div class='code'> |
||||
<p><pre><code data-trim class='python'> |
||||
def addSeven(foo): # "Unused argument 'foo'" |
||||
foo += [7] |
||||
</code></pre></p> |
||||
</div> |
||||
|
||||
<p>O problema é a questão de referência para objetos |
||||
mutáveis. O código em si está errado.</p> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>bare-except</code></h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>O que é o erro</h2> |
||||
|
||||
<div class='code'> |
||||
<p><pre><code data-trim class='python'> |
||||
try: |
||||
func() |
||||
except Exception e: |
||||
pass |
||||
</code></pre></p> |
||||
</div> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>Solução</h2> |
||||
|
||||
<p>Capture apenas as exceções que você sabe lidar.</p> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>no-self-use</code></h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>O que é o erro</h2> |
||||
|
||||
<div class='code'> |
||||
<p><pre><code data-trim class='python'> |
||||
class A(object): |
||||
def func(self, a): |
||||
return a * 2 |
||||
</code></pre></p> |
||||
</div> |
||||
</section> |
||||
|
||||
<section> |
||||
<h2>Solução</h2> |
||||
|
||||
<p>A solução mais "correta" é tirar a função da classe e deixar |
||||
fora do objeto.</p> |
||||
|
||||
<p class='fragment'>Não sendo possível, |
||||
<code># pylint:disable=no-self-use</code> antes da função. |
||||
</p> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>old-style-class</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>super-on-old-class</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>no-init</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>super-init-not-called</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>attribute-defined-outside-init</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>abstract-method</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>arguments-differ</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>no-member</code> e <code>maybe-no-member</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>no-value-for-parameter</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>protected-access</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>too-few-public-methods</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>too-many-ancestors</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>too-many-arguments</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>too-many-branches</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>too-many-instance-attributes</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>too-many-lines</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>too-many-locals</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>too-many-public-methods</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>too-many-statements</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>invalid-name</code></h2> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2><code>star-args</code></h2> |
||||
</section> |
||||
</section> |
||||
</div> |
||||
</div> |
||||
|
||||
<script src="_external/head.min.js"></script> |
||||
<script src="_external/reveal.min.js"></script> |
||||
|
||||
<script> |
||||
|
||||
// Full list of configuration options available here: |
||||
// https://github.com/hakimel/reveal.js#configuration |
||||
Reveal.initialize({ |
||||
controls: true, |
||||
progress: true, |
||||
history: true, |
||||
center: true, |
||||
|
||||
theme: 'night', |
||||
transition: 'linear', |
||||
|
||||
// Optional libraries used to extend on reveal.js |
||||
dependencies: [ |
||||
{ src: '_external/classList.js', condition: function() { return !document.body.classList; } }, |
||||
{ src: '_external/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, |
||||
{ src: '_external/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, |
||||
{ src: '_external/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, |
||||
{ src: '_external/zoom.js', async: true, condition: function() { return !!document.body.classList; } }, |
||||
{ src: '_external/notes.js', async: true, condition: function() { return !!document.body.classList; } } |
||||
] |
||||
}); |
||||
|
||||
</script> |
||||
|
||||
</body> |
||||
</html> |
||||
|
||||
<!-- vim:set et ts=4 sts=4 st=4: > |