Skip to content

Instantly share code, notes, and snippets.

View diogomachado's full-sized avatar
🎯
Focusing

Diogo Machado diogomachado

🎯
Focusing
View GitHub Profile
@diogomachado
diogomachado / gist:31e9f5547d4fe0ac8056
Created March 23, 2016 23:17
Redirect http to https
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
@diogomachado
diogomachado / gist:d76ac14f4aa6ebfa71f9ac28444233fa
Created July 15, 2016 23:51
Instagram captura imagens hashtag.
// Para obter o token
// $json = file_get_contents("https://instagram.com/oauth/authorize/?client_id=33ba683f581e4c8faefd4cd38d948131&redirect_uri=http://www.sofisticatta.dev&scope=public_content&response_type=token");
// $data = json_decode($json);
// dd($data);
// die();
// $json = file_get_contents("https://api.instagram.com/v1/tags/looksofisticatta/media/recent/?access_token=311684193.33ba683.9dae3610190549e0aa1bf6caa41c065b");
// $data = json_decode($json);
@diogomachado
diogomachado / exemplo-modulepattern.js
Last active August 19, 2016 19:49
Padrão de projeto Javascript (Module Pattern)
// Exemplo com encapsulamento de métodos
var pedidoMesa1 = (function() {
var pedido = {};
pedido.alertar = function(msg){
alert(msg);
};
pedido.addItem = function(){
@diogomachado
diogomachado / config.xml
Last active August 29, 2016 17:48
Configurações de ícones e splashscreen - Plataforma Windows - Cordova/Phonegap/ionic
<platform name="windows">
<icon src="resources/windows/icon/Square150x150Logo.scale-100.png" width="150" height="150" />
<icon src="resources/windows/icon/Square150x150Logo.scale-240.png" width="360" height="360" />
<icon src="resources/windows/icon/Square30x30Logo.scale-100.png" width="30" height="30" />
<icon src="resources/windows/icon/Square310x310Logo.scale-100.png" width="310" height="310" />
<icon src="resources/windows/icon/Square44x44Logo.scale-240.png" width="106" height="106" />
<icon src="resources/windows/icon/Square70x70Logo.scale-100.png" width="70" height="70" />
<icon src="resources/windows/icon/Square71x71Logo.scale-240.png" width="170" height="170" />
<icon src="resources/windows/icon/StoreLogo.scale-100.png" width="50" height="50" />
<icon src="resources/windows/icon/StoreLogo.scale-240.png" width="120" height="120" />
@diogomachado
diogomachado / gist:b3d72a9c03056d2e4fd843c57aff5da2
Created September 19, 2016 23:10
backbutton - Cordova (Está usando ngCordova, mas pode fazer um confirm nativo também)
// Fica escutando o evento do botão voltar
// ////////////////////////
document.addEventListener("backbutton", function(){
// Se estou na home, então pergunto se quer sair do app
if ($location.path() == '/'){
// Mando uma mensagem na cara do usuário, perguntando se quer sair
$cordovaDialogs.confirm('' , 'Deseja sair do aplicativo?', ['Sim','Não']).then(function(buttonIndex) {
@diogomachado
diogomachado / app.css
Created April 21, 2017 21:20
Livro - CSS spinner - capítulo 5
.spinner {
width: 40px;
height: 40px;
position: relative;
margin: 100px auto;
}
.double-bounce1, .double-bounce2 {
width: 100%;
height: 100%;
@diogomachado
diogomachado / gist:134e0b9b609327141b2a906e04b041e7
Created April 22, 2017 20:03
Livro - Função para encontrar empresas - capitulo 5
// Realiza a busca na plataforma Firebase
function encontrar(uid){
// Inicializa
var db = firebase.database();
// Busca a referencia, entenda como uma URL, empresas no Firebase é representando por /empresas
var empresas = db.ref('empresas');
// Prepara a busca filtrando
@diogomachado
diogomachado / gist:8c1d088b0b96b854a86fc0e17f733bd1
Created April 30, 2017 22:20
Livro - CSS para offline/online
.offline-alert{
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 28;
background: rgba(255, 255, 255, 0.95);
display: flex;
justify-content: center;
@diogomachado
diogomachado / gist:584c93a447114a8a65e6d9aff0ce5581
Created May 10, 2017 19:16
Javascript - Reduzir imagem proporcionalmente
// Valores da imagem original
var width = 600, height = 300;
// Redução desejada
var width_new = 300;
// Novo tamanho baseado na redução
var height_new = Math.round(((height/width) * width_new));
@diogomachado
diogomachado / gist:c5921e697cee4ccf590dc8090585502c
Created May 11, 2017 12:44
Text overflow - Texto com overflow e três pontos
.truncate-link {
max-width: 100%;
display: inline-block;
vertical-align: middle;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}