Post on 15-Jul-2015
transcript
O Q U E FA Z U M S O F T W A R E R U I M ?
• Bugs
• Difícil de usar
• Código difícil:
• De entender
• De estender
• De mudar
– R O B P I K E
“The heart of Unix philosophy is the idea that the power of a system comes more from the
relationships among programs than from the programs themselves.”
I M P O N D O L I M I T E S
• Passar o máximo de tempo possível na shell.
• Evitar root. Customizar pouco.
• Otimizar sempre.
220.181.108.101 - - [20/Jun/2012:19:31:01 +0200] "GET / HTTP/1.1" 200 912 "-" "Mozilla/5.0 (compatible;Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"123.125.68.79 - - [20/Jun/2012:19:53:24 +0200] "GET / HTTP/1.1" 200 625 "-" "Mozilla/5.0 (compatible;Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"178.154.210.252 - - [20/Jun/2012:19:54:10 +0200] "GET /?C=S;O=A HTTP/1.1" 200 663 "-" "Mozilla/5.0(compatible; YandexBot/3.0; +http://yandex.com/bots)"74.125.126.102 - - [20/Jun/2012:20:15:28 +0200] "GET / HTTP/1.1" 200 606 "http://www.google.com/url?sa=t&rct=j&q=error&source=web&cd=1&ved=0CFAQFjAG&url=http%3A%2F%2Fwww.isrolab.com%2F&ei=GxPiT5PsL4e04AHPtgE&usg=AFQjCNHnmjmdkUV584ORIpOXz7zAPX0UHQ" "Mozilla/4.0 (compatible; MSIE 7.0; WindowsNT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; InfoPath.2; .NETCLR 3.0.4506.2152; .NET CLR 3.5.30729)"74.125.126.103 - - [20/Jun/2012:20:15:29 +0200] "GET /icons/blank.gif HTTP/1.1" 200 383 "http://www.isrolab.com/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR3.5.30729)"74.125.126.93 - - [20/Jun/2012:20:15:29 +0200] "GET /icons/folder.gif HTTP/1.1" 200 460 "http://www.isrolab.com/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR3.5.30729)"74.125.126.82 - - [20/Jun/2012:20:15:30 +0200] "GET /favicon.ico HTTP/1.1" 404 449 "-" "Mozilla/4.0(compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR3.5.21022; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"184.82.92.239 - - [20/Jun/2012:21:03:44 +0200] "GET /logs/access.log HTTP/1.1" 200 2519 "http://isrolab.com/""Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT5.1; SV1) ; .NET CLR 3.5.30729)"173.236.21.106 - - [20/Jun/2012:21:16:22 +0200] "GET /robots.txt HTTP/1.0" 404 488 "-" "Mozilla/5.0(compatible; MJ12bot/v1.4.3; http://www.majestic12.co.uk/bot.php?+)"173.236.21.106 - - [20/Jun/2012:21:16:23 +0200] "GET / HTTP/1.0" 200 621 "-" "Mozilla/5.0 (compatible;MJ12bot/v1.4.3; http://www.majestic12.co.uk/bot.php?+)"213.186.122.2 - - [20/Jun/2012:21:27:53 +0200] "GET /logs/?C=D;O=D HTTP/1.1" 200 658 "-" "Mozilla/5.0(compatible; AhrefsBot/3.0; +http://ahrefs.com/robot/)"66.249.72.65 - - [20/Jun/2012:21:28:00 +0200] "GET /robots.txt HTTP/1.1" 404 508 "-" "Mozilla/5.0 (compatible;Googlebot/2.1; +http://www.google.com/bot.html)"66.249.72.65 - - [20/Jun/2012:21:28:00 +0200] "GET /logs/ HTTP/1.1" 200 723 "-" "Mozilla/5.0 (compatible;Googlebot/2.1; +http://www.google.com/bot.html)"123.125.71.44 - - [20/Jun/2012:21:38:57 +0200] "GET / HTTP/1.1" 200 913 "-" "Mozilla/5.0 (compatible;Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"220.181.108.88 - - [20/Jun/2012:21:39:48 +0200] "GET / HTTP/1.1" 200 913 "-" "Mozilla/5.0 (compatible;Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"178.154.210.252 - - [20/Jun/2012:21:45:12 +0200] "GET /logs/ HTTP/1.1" 200 728 "-" "Mozilla/5.0 (compatible;YandexBot/3.0; +http://yandex.com/bots)"139.18.2.209 - - [20/Jun/2012:22:31:43 +0200] "GET / HTTP/1.1" 200 912 "-" "findlinks/2.6 (+http://wortschatz.uni-leipzig.de/findlinks/)"
#!/bin/bash[~/Apache] $ tail -n 1 access.log192.210.213.91 - - [08/Jun/2014:19:42:34 -0700] "GET /logs/access.log HTTP/1.1" 200 4663 "http://redlug.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1" "redlug.com"
#!/bin/bash[~/Apache]$ head -n 1 access.log1.202.218.8 - - [20/Jun/2012:19:05:12 +0200] "GET /robots.txt HTTP/1.0" 404 492 "-" "\"Mozilla/5.0"
#!/bin/bash[~/Apache]$ head -n 1 access.log1.202.218.8 - - [20/Jun/2012:19:05:12 +0200] "GET /robots.txt HTTP/1.0" 404 492 "-" “\"Mozilla/5.0"
#!/bin/bash[~/Apache]$ head -n 1 access.log1.202.218.8 - - [20/Jun/2012:19:05:12 +0200] "GET /robots.txt HTTP/1.0" 404 492 "-" “\"Mozilla/5.0"
[~/Apache]$ head -n 1 access.log | awk '{print $1}'1.202.218.8
#!/bin/bash[~/Apache]$ head -n 1 access.log1.202.218.8 - - [20/Jun/2012:19:05:12 +0200] "GET /robots.txt HTTP/1.0" 404 492 "-" “\"Mozilla/5.0"
[~/Apache]$ head -n 1 access.log | awk '{print $1}'1.202.218.8
[~/Apache]$ awk '/access.log/' access.log | awk '{print $1}'31.184.238.16431.184.238.16477.27.18.6731.184.238.16431.184.238.16431.184.238.16431.184.238.16431.184.238.164
#!/bin/bash[~/Apache] $ awk '/access.log/' access.log | \ awk '{print $1}' | \ sort | \ uniq -c | \ sort -r
#!/bin/bash[~/Apache] $ awk '/access.log/' access.log | \ awk '{print $1}' | \ sort | \ uniq -c | \ sort -r
41 31.184.238.164 2 192.210.213.91 1 77.27.18.67 1 192.227.243.66 1 189.120.185.4
[~/symfony] $ git branch
* 2.7
[~/symfony] $ git log | wc -l
299 348
[~/symfony] $ alias rank="sort | uniq -c | sort -nr | head -n 3“
[~/symfony] $ git branch
* 2.7
[~/symfony] $ git log | wc -l
299 348
[~/symfony] $ alias rank="sort | uniq -c | sort -nr | head -n 3“
[~/symfony] $ git branch
* 2.7
[~/symfony] $ git log | wc -l
299 348
[~/symfony] $ alias rank="sort | uniq -c | sort -nr | head -n 3“
[~/symfony] $ git branch
* 2.7
[~/symfony] $ git log | wc -l
299 348
[~/symfony] $ alias rank="sort | uniq -c | sort -nr | head -n 3“
[~/symfony] $ git branch
* 2.7
[~/symfony] $ git log | wc -l
299 348
[~/symfony] $ alias rank="sort | uniq -c | sort -nr | head -n 3“
[~/symfony] $ git branch
* 2.7
[~/symfony] $ git log | wc -l
299 348
[~/symfony] $ alias rank="sort | uniq -c | sort -nr | head -n 3“
[~/symfony] $ git log --format=%an | rank
10725 Fabien Potencier
1211 Bernhard Schussek
371 Tobias Schultze
[~/symfony] $ git config alias.author "log --format=%an"
[~/symfony] $ git author —since 2014-01-01 | rank
2444 Fabien Potencier
357 Nicolas Grekas
262 Bernhard Schussek
[~/symfony] $ cd ../zf2
[~/zf2] $ git author | rank
7963 Matthew Weier O'Phinney
1647 Marco Pivetta
782 Maks3w
[~/zf2] $ git author --since 2014-01-01 | rank
1507 Marco Pivetta
1048 Matthew Weier O'Phinney
215 Abdul Malik Ikhsan
1 #!/usr/bin/env php 2 <?php 3 /** 4 * hdate (Human Date) 5 * 6 * Converts a human (relative) date to an specific date. 7 * Usage: hdate "+10 day" 11 */ 12 13 $relativeDate = $argv[1]; 14 $date = new DateTime($relativeDate); 15 16 echo $date->format('Y-m-d');
[~/zf2] $ git author --since `hdate -1year` | rank
1358 Marco Pivetta
564 Matthew Weier O'Phinney
132 Abdul Malik Ikhsan
[~/zf2] $ git diff --name-only HEAD^
library/Zend/Db/Sql/AbstractSql.php
tests/ZendTest/Db/Sql/AbstractSqlTest.php
tests/ZendTest/Db/Sql/ExpressionTest.php
[~/zf2] $ git diff --name-only HEAD^
library/Zend/Db/Sql/AbstractSql.php
tests/ZendTest/Db/Sql/AbstractSqlTest.php
tests/ZendTest/Db/Sql/ExpressionTest.php
[~/zf2] $ vim `git diff --name-only HEAD^`
P R I N C Í P I O S
• Tudo é um arquivo
• Tipo de Informação? Texto.
• Escopos diferentes? Quebra de linha.
• Cache? Nah.
• Erros? Yeah!