Skip to content

Instantly share code, notes, and snippets.

View Scemist's full-sized avatar
🖌️
Painting Algorithms

Lucas Gonçalves S. Scemist

🖌️
Painting Algorithms
View GitHub Profile
@Scemist
Scemist / git-main-commands.md
Last active October 4, 2022 20:59
Main Git Commands
@Scemist
Scemist / LaravelInitProject.md
Last active August 11, 2022 11:59
Laravel Init Project

Init a Project

'Berlin' is a example of the name of project. 'Bootstrap' is a example of the ui framework used.

  • laravel new berlin
  • Create the database in your DBMS
  • Put the database credentials in .env file
  • You need enter in project now: cd berlin
@Scemist
Scemist / vscode-settings.json
Last active May 2, 2022 14:49
VS Code Configuration
{
"editor.fontFamily": "Source Code Pro",
"editor.lineHeight": 2.2,
"editor.fontSize": 13.5,
"workbench.colorTheme": "Tokyo Night Storm",
"workbench.iconTheme": "material-icon-theme",
"workbench.tree.indent": 16,
"material-icon-theme.hidesExplorerArrows": true,
"material-icon-theme.languages.associations": { "php": "php_elephant" },
@Scemist
Scemist / search-in-table.js
Last active October 14, 2022 18:16
JavaScript Table Filter Rows By Key Search v3.0
// Called by the input search element: onkeyup="pesquisar()"
const pesquisar = (keyWord, tableKey = 'table') => {
const
oldBody = document.querySelector(`${tableKey} tbody`),
keyWord = keyRaw.toUpperCase(),
newBody = oldBody.cloneNode(true)
for (let row of newBody.children) {
row.style.display = row.innerText.toUpperCase().includes(keyWord)
@Scemist
Scemist / leaflet-mapa.js
Last active June 7, 2022 14:59
Leaflet Elegant Code
const mapa = _ => {
const mapa = L.map('mapa-div').setView([51.505, -0.09], 13)
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1,
accessToken: 'your.mapbox.access.token'
@Scemist
Scemist / synchronous-ajax.js
Last active May 2, 2022 14:32
Elegant Ajax in JS with XMLHttpRequest
const xhr = new XMLHttpRequest()
xhr.open('GET', 'server.php')
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded ')
xhr.onreadystatechange = _ => {
if (xhr.readyState === 4 && xhr.status === 200) {
console.log(xhr.responseText)
} else {
console.log('Loading')
}
@Scemist
Scemist / save-image.php
Last active May 2, 2022 14:23
Code to Save Image in PHP
<?php
// Cadastrar - função salvarImagem com atualizar false
// Atualizar - função salvarImagem com atualizar true
// Apagar - função apagarImagem com atualizar false
function salvarImagem($tabela, $referencia, $atualizar) {
global $conexao;
// Se existir uma imagem
@Scemist
Scemist / roteamento.md
Created December 21, 2021 16:44
Roteamento

A maioria dos roteadores domésticos usa um caso especial de NAT chamado PAT.

Você também o verá referido como NAPT ou IP Masquerading. Todos os três últimos termos significam a mesma coisa no uso geral. (As siglas - Tradução de endereço de rede / Tradução de endereço de porta / Tradução de porta de endereço de rede)

Quando o pacote sai de sua máquina interna, o endereço de origem é reescrito conforme você sabe. A porta de origem também é alterada, geralmente para um número alto, e o roteador mantém uma tabela de tradução de endereços.

Por exemplo, digamos que você tenha uma máquina cliente que vai para www.google.com. Seu computador (por exemplo, 192.168.1.100) procura esse endereço e faz uma conexão TCP para 72.14.204.147 na porta 80 do seu endereço IP interno, usando uma porta de origem aleatória.

Para o seu computador, a conexão é parecida com esta:

@Scemist
Scemist / vanced-operators.php
Last active June 28, 2022 13:19
Advanced PHP Operators
<?php
$nome?->$email?->$cpf // Nullsafe Operator
$valor = true ? 'um' : 'dois'; // Ternary Operator
$valor = $test ?? 'é null'; // Null Coalescing
$valor = $test ?: 0 ?: null ?: 2 ?: 'asd'; // Elvis Operator
@Scemist
Scemist / media-breakpoints.css
Last active May 2, 2022 14:21
CSS Media Query Breakpoints
/* Portrait Phones, less than 576px */
@media (max-width: 575px)
/* Landscape Phones, 576px and up */
@media (min-width: 576px)
/* Tablets, 768px and up */
@media (min-width: 768px)
/* Desktops, 992px and up */