Skip to content

Instantly share code, notes, and snippets.

@diogoca
diogoca / gist:c1d45f643427126dcb01c4fb34b38b54
Created November 4, 2020 16:20
VSCode installed extensions
Docker
PHP Debug
PHP DockBlocker
PHP Getters & Setters
PHP Intelephense
@diogoca
diogoca / scroll-infinito.html
Created May 17, 2018 16:36
Scroll infinito com jQuery
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script>
var carregando = false;
var paginaAtual = 1;
function carregarConteudo(pagina) {
@diogoca
diogoca / encontrar_soma.php
Created April 5, 2018 14:19
Encontrar soma em uma lista de possíveis arrays
<?php
static $values = array( 15.92, 53.27, 244.28, 388.46, 3.14, 2.92, 18.22, 4.03 );
static $expected = 297.55;
static $precision = 100; /* para não ter problemas com ponto flutuante */
$target = floor( $expected * $precision );
$len = count( $values );
for( $i = 1; $i < pow( 2, $len ); $i++ ) {
$soma = 0;
$set = array();
@diogoca
diogoca / gist:dbe29306fe6fe5e7dc6556c2667123d8
Created March 7, 2018 16:42
Integrating React.js Into a PHP Application
https://pt.slideshare.net/andrewrota/integrating-reactjs-into-a-php-application
@diogoca
diogoca / cart-vanilla.html
Created January 7, 2018 23:11
Javascript with Redux Cart Example
<!DOCTYPE html>
<html>
<head>
<title>Redux basic example</title>
<script src="https://unpkg.com/redux@latest/dist/redux.min.js"></script>
</head>
<body>
<h2>Itens</h2>
<button class="item">Apple</button>
<button class="item">Banana</button>
@diogoca
diogoca / gist:704edda6094041d476172afb63059e4c
Created December 24, 2017 13:57
JavaScript Promise Example with API
<script>
function fetchPhotos() {
return fetch('https://jsonplaceholder.typicode.com/photos');
}
function fetchPhoto(id) {
return fetch('https://jsonplaceholder.typicode.com/photos/' + id);
}
@diogoca
diogoca / promise.js
Created December 24, 2017 13:29
JavaScript Promise examples
<script>
function getSalary(salary) {
return new Promise(resolve => {
setTimeout(() => {
resolve(salary);
}, 500);
});
}
@diogoca
diogoca / gist:c541d3a65998710712468fb27e096469
Created September 25, 2017 16:38
Disable ssh root login
https://mediatemple.net/community/products/dv/204643810/how-do-i-disable-ssh-login-for-the-root-user
@diogoca
diogoca / gist:f49fd28d081c3ba9c98ff4418bca8263
Created September 25, 2017 16:37
SSH chmod permissions
mkdir -p /home/user/.ssh
ssh-keygen -t rsa
touch /home/user/.ssh/authorized_keys
touch /home/user/.ssh/known_hosts
chown -R user:user /home/user/.ssh
chmod 700 /home/user/.ssh
chmod 600 /home/user/.ssh/id*
chmod 644 /home/user/.ssh/id*.pub
chmod 644 /home/user/.ssh/authorized_keys
chmod 644 /home/user/.ssh/known_hosts
https://serversforhackers.com/c/nginx-caching