Skip to content

Instantly share code, notes, and snippets.

View marttosc's full-sized avatar

Gustavo Marttos marttosc

View GitHub Profile
@marttosc
marttosc / gist:5561788
Last active December 17, 2015 05:59
Convertendo imagem usando PHP #gustavomarttos
<?php
function converterImagem($caminhoImagem, $novaImagem, $extensao, $unlink = true) {
/**
* Resgata a largura e altura da imagem que deve ser convertida.
*/
list($larguraOriginal, $alturaOriginal) = getimagesize($caminhoImagem);
$extensao = strtolower($extensao);
$imagem = null;
$tci = null;
@marttosc
marttosc / MC.PHP_A2_E1
Created March 26, 2014 22:45
Minicurso PHP (Aula 2) - Formulário $_POST [e.g. 1]
<?php
header("Content-type: text/html; charset=utf-8");
date_default_timezone_set("America/Sao_Paulo");
?>
<html>
<head>
<title>Formulário via POST</title>
</head>
<body>
<form method="post" action="dobro.php">
@marttosc
marttosc / MC.PHP_A2_E1
Created March 26, 2014 22:46
Minicurso PHP (Aula 2) - Formulário $_POST [e.g. 1]
<?php
header("Content-type: text/html; charset=utf-8");
date_default_timezone_set("America/Sao_Paulo");
?>
<html>
<head>
<title>Formulário via POST</title>
</head>
<body>
<form method="post" action="dobro.php">
@marttosc
marttosc / install_elemos.sh
Last active February 14, 2024 10:32
HowTo: Install developer softwares in Elementary OS
#!/bin/bash
# Author: Gustavo Marttos <marttosc@gmail.com>
#
# Run this scrupt with sudo, e.g.: sudo ./install_elemos.sh
COLOR_DEFAULT='\033[0;0;39m'
COLOR_WHITE='\033[1;37m'
COLOR_BLACK='\033[0;30m'
COLOR_BLUE='\033[0;34m'
@marttosc
marttosc / CheckTemporaryPassword.php
Created May 25, 2016 17:36
Using middleware to change response
<?php
namespace App\Http\Middleware;
use Closure;
class PasswordTemporary
{
/**
* Handle an incoming request.
@marttosc
marttosc / Card.php
Created May 30, 2016 16:40
Query scope - Laravel 5.2
<?php
namespace App\Card;
use Illuminate\Database\Eloquent\Model;
class Card extends Model
{
...
@marttosc
marttosc / script-oracle.sql
Last active June 14, 2016 21:19
MySQL DML - Locação
# Generated from SQLines
SELECT CLI.NOME,
(
CASE WHEN TPC.CODIGO = 1 THEN
SUM(VEI.VALORKM * (DEV.KMATUAL - VEI.KM) + (SELECT SUM(D.VALOR) FROM devolucao D WHERE D.LOCACAO = LOC.CODIGO)) ELSE
SUM(VEI.VALORDIARIA * DEV.DATAHORA- LOC.DATAHORA + (SELECT SUM(D.VALOR) FROM devolucao D WHERE D.LOCACAO = LOC.CODIGO))
END
) TOTAL
FROM cliente CLI, locacao LOC, tipocobranca TPC, veiculo VEI, devolucao DEV
@marttosc
marttosc / filter.txt
Last active May 9, 2019 18:05
AdBlock Filters
@@*.dx.com/$document
@@http://*.wikipedia.org/$document
@@|http://download.cyanogenmod.org/|$document
@@|http://www.flaticon.com/|$document
@@|https://outlook.office365.com/owa/|$document
@@|https://play.google.com/music/listen|$document
@@||microsoftonline.com/$document
@@||cyanogenmod.org/$document
@@||app.evrdy.com/$document
@@||www.bradesco.com.br/$document
@marttosc
marttosc / fix-qca6174.sh
Created August 11, 2016 16:53
Ubuntu 16.04 - Wifi problem with Qualcomm Atheros QCA6174 802.11ac
#!/bin/sh
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root!" 1>&2
exit 1
fi
cd /tmp
mkdir -p /lib/firmware/ath10k/QCA6174/hw3.0/
@marttosc
marttosc / event.js
Created August 24, 2016 18:49
Bootstrap modal: event close
$(document).on('hidden.bs.modal', '.modal', function () {
var player = $(this).find('.modal-content video');
player.pause();
});