Skip to content

Instantly share code, notes, and snippets.

View gist:c1d45f643427126dcb01c4fb34b38b54
Docker
PHP Debug
PHP DockBlocker
PHP Getters & Setters
PHP Intelephense
@diogoca
diogoca / scroll-infinito.html
Created May 17, 2018
Scroll infinito com jQuery
View scroll-infinito.html
<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 Apr 5, 2018
Encontrar soma em uma lista de possíveis arrays
View encontrar_soma.php
<?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 Mar 7, 2018
Integrating React.js Into a PHP Application
View gist:dbe29306fe6fe5e7dc6556c2667123d8
https://pt.slideshare.net/andrewrota/integrating-reactjs-into-a-php-application
@diogoca
diogoca / cart-vanilla.html
Created Jan 7, 2018
Javascript with Redux Cart Example
View cart-vanilla.html
<!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 Dec 24, 2017
JavaScript Promise Example with API
View gist:704edda6094041d476172afb63059e4c
<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 Dec 24, 2017
JavaScript Promise examples
View promise.js
<script>
function getSalary(salary) {
return new Promise(resolve => {
setTimeout(() => {
resolve(salary);
}, 500);
});
}
View gist:c541d3a65998710712468fb27e096469
https://mediatemple.net/community/products/dv/204643810/how-do-i-disable-ssh-login-for-the-root-user
View gist:f49fd28d081c3ba9c98ff4418bca8263
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