Skip to content

Instantly share code, notes, and snippets.

View matpratta's full-sized avatar

Matheus Pratta matpratta

View GitHub Profile
@matpratta
matpratta / smooth.jquery.js
Last active December 3, 2015 18:05
jQuery plugin to smoothly scroll the page when a link referencing an element ID is clicked.
/* smooth.jquery.js (ver 1.0.3)
* by Matheus Pratta (http://matheus.io)
* Requires: jQuery
* Optional: jQuery UI (for animations other than 'linear' and 'swing') - required by default
*/
// Thanks Sebastien Lorber for this snippet
function canonicalize (url) {
var div = document.createElement('div');
div.innerHTML = '<a></a>';
@matpratta
matpratta / responsive.js
Created July 25, 2015 01:40
Fixes page scroll "jumping" on mobile devices with auto-hiding address bar, when it contains a 100% height element.
/* responsive.js (v. 1.0.0)
* by Matheus Pratta (matheus.io)
* Fixes the page scroll from "jumping" when the user scrolls from a mobile device which auto-hides the address bar.
* Note: for 100% height elements, instead of seeing a jump in the scroll, the user may see a jump on the element itself (mostly when it's vertically centered)
* Requires: jQuery
*/
$(document).ready(function() {
$(window)
.scroll(function() {
window._scroll_pos = $(window).scrollTop();
@matpratta
matpratta / normalize.min.css
Created September 1, 2015 12:26
My default CSS normalize, plus box reset
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}
<?php
/*
-=- Script de proxy para SHOUTcast -=-
// v1.0
Script original de referência: http://support.spacialaudio.com/forums/viewtopic.php?f=13&t=16858
@matpratta
matpratta / Benchmark.php
Created January 13, 2017 13:05
PHP / Laravel 5 Benchmark Tool
<?php
namespace App;
class Benchmark {
private static $_times = [];
private static $_last_time = null;
private static $_last_name = null;
public static function run ($name = 'Unnamed Test') {
@matpratta
matpratta / array_multilevel.php
Last active January 18, 2017 11:58
PHP helper to retrieve and set data on multi-level arrays
public static function array_multilevel (&$array, $name, $fn = null, $separator = '.') {
$name_tree = explode($separator, $name);
if (count($name_tree) > 1) {
$name_tree = array_reverse($name_tree);
$name = array_pop($name_tree);
$name_tree = array_reverse($name_tree);
$name_tree = implode($separator, $name_tree);
if (!isset($array[$name]))
@matpratta
matpratta / whatever.css
Created May 8, 2017 13:10
Always-visible element with shadows
/* Apply this to a class, so the object is always visible */
.some-class {
box-shadow: inset 0px 0px 2px rgba(255,255,255,0.35), 0px 0px 2px rgba(0, 0, 0, 0.5);
}
@matpratta
matpratta / cf7_cidades_estados.js
Last active July 7, 2017 14:02
Plugin para o Contact Form 7 que converte campos de texto "Cidade/Estado" em campos select de preenchimento automático
// Plugin de Cidade/Estado para ContactForm7
// Por Matheus Pratta <eu@matheus.io>
// Uso: cf7_cidades_estados('#seletorEstado', '#seletorCidade');
function cf7_cidades_estados (iEstado, iCidade) {
var base_dados = {"Acre":[{"id":79,"nome":"Acrelândia","estado_id":1,"created_at":null,"updated_at":null},{"id":80,"nome":"Assis Brasil","estado_id":1,"created_at":null,"updated_at":null},{"id":81,"nome":"Brasiléia","estado_id":1,"created_at":null,"updated_at":null},{"id":82,"nome":"Bujari","estado_id":1,"created_at":null,"updated_at":null},{"id":83,"nome":"Capixaba","estado_id":1,"created_at":null,"updated_at":null},{"id":84,"nome":"Cruzeiro do Sul","estado_id":1,"created_at":null,"updated_at":null},{"id":85,"nome":"Epitaciolândia","estado_id":1,"created_at":null,"updated_at":null},{"id":86,"nome":"Feijó","estado_id":1,"created_at":null,"updated_at":null},{"id":87,"nome":"Jordão","estado_id":1,"created_at":null,"updated_at":null},{"id":88,"nome":"Mâncio Lima","estado_id":1,"created_at":null,"updated_at":null},{"
### Keybase proof
I hereby claim:
* I am matheusmk3 on github.
* I am matt_pratta (https://keybase.io/matt_pratta) on keybase.
* I have a public key ASCmjAFCKokPiTDRDM9RhHwXtS0RX3qh2bb6EBfWYz4Vzgo
To claim this, I am signing this object:
@matpratta
matpratta / google-font-packager.php
Created February 11, 2018 23:20
CLI tool to download Google Fonts into a local directory, in WOFF2 format, while rewriting Google Fonts CSS to point to local files.
<?php
/************************************************************************************************
* Google Font Packager
* Version 1.0 (2018-02-11)
* by Matheus Pratta (https://github.com/matheusmk3)
*/
if (!isset($argv[1]))
die ('Usage: google-font-packager.php [google-font-import-url [output-file.css]]');