Skip to content

Instantly share code, notes, and snippets.

Diogo Alves diogoca

Block or report user

Report or block diogoca

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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
@diogoca
diogoca / components.weather-list.js
Last active Apr 18, 2017
Loading model on component
View components.weather-list.js
import Ember from 'ember';
export default Ember.Component.extend({
weather: Ember.inject.service(),
didInsertElement() {
this.get('weather').current().then((weather) => {
this.set('currentWeather', weather);
});
}
You can’t perform that action at this time.