This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//standalo ie9+ code | |
/** | |
* @param v Number Number to be formatted | |
* @param m String Milliar delimitter. Default: '.' (pt-br). | |
* @param d String Decimal delimitter. Default: ',' (pt-br). | |
* @return String Formatted number | |
*/ | |
function formatCurrency(v,m,d){ | |
var r = v.toFixed(2).split(/\.|-/), | |
m = m || '.', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* === Scroller === | |
* Basta adicionar a classe "scroller" para algum elemento e atribuir o seletor ao atributo href ou data-target; | |
* Exemplos: | |
* <a href="#wrapper" class="scroller">Topo</a> | |
* <span class="scroller" data-target="#wrapper">Topo</span> | |
*/ | |
jQuery(document).ready(function(){ | |
var screen = $('html, window, body'), | |
regex = /.*(?=#[^\s]+$)/; //strip for ie7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the semi-colon before function invocation is a safety net against concatenated | |
// scripts and/or other plugins which may not be closed properly. | |
;(function ( $, window, undefined ) { | |
// undefined is used here as the undefined global variable in ECMAScript 3 is | |
// mutable (ie. it can be changed by someone else). undefined isn't really being | |
// passed in so we can ensure the value of it is truly undefined. In ES5, undefined | |
// can no longer be modified. | |
// window and document are passed through as local variables rather than globals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function html_decode(text){ | |
var div = document.createElement("div"); | |
div.innerHTML = text; | |
return ("textContent" in div) ? div.textContent : div.innerText ; | |
} | |
function html_encode(str){ | |
var div = document.createElement("div"); | |
div[("textContent" in div) ? "textContent" : "innerText"] = str; | |
return div.innerHTML; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function pagination ($index, $teto, $amplitude = 7, $piso = 1){ | |
$padding = intval($amplitude/2); | |
$amplitude = min(array($amplitude,$teto)); | |
$left = $padding; | |
$right = $amplitude - $left - 1; | |
if($index - $padding < $piso){ | |
$left = $index - $piso; | |
$right = $amplitude - ($left + 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Acre": ["Acrel\u00e2ndia","Assis Brasil","Brasil\u00e9ia","Bujari","Capixaba","Cruzeiro do Sul","Epitaciol\u00e2ndia","Feij\u00f3","Jord\u00e3o","M\u00e2ncio Lima","Manoel Urbano","Marechal Thaumaturgo","Pl\u00e1cido de Castro","Porto Acre","Porto Walter","Rio Branco","Rodrigues Alves","Santa Rosa do Purus","Sena Madureira","Senador Guiomard","Tarauac\u00e1","Xapuri"], | |
"Alagoas": ["\u00c1gua Branca","Anadia","Arapiraca","Atalaia","Barra de Santo Ant\u00f4nio","Barra de S\u00e3o Miguel","Batalha","Bel\u00e9m","Belo Monte","Boca da Mata","Branquinha","Cacimbinhas","Cajueiro","Campestre","Campo Alegre","Campo Grande","Canapi","Capela","Carneiros","Ch\u00e3 Preta","Coit\u00e9 do N\u00f3ia","Col\u00f4nia Leopoldina","Coqueiro Seco","Coruripe","Cra\u00edbas","Delmiro Gouveia","Dois Riachos","Estrela de Alagoas","Feira Grande","Feliz Deserto","Flexeiras","Girau do Ponciano","Ibateguara","Igaci","Igreja Nova","Inhapi","Jacar\u00e9 dos Homens","Jacu\u00edpe","Japaratinga","Jaramataia","Jequi\u00e1 da Praia","Jo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* An array forEach with a delay between steps. | |
* | |
* @param {Function} callback Function to execute for each element. It receives three arguments, the element value, the element index and the array being traversed, respectivily. | |
* @param {Number} timeout Number of milliseconds that the function call should be delayed by. | |
* @param {Object} thisArg Object to use as this when executing callback. | |
* @this {Array} | |
* @return {undefined} | |
*/ | |
Array.prototype.delayedForEach = function(callback, timeout, thisArg){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validateDate(data){ | |
var p = data.split("/"), | |
isNumber = /^\d{1,2}\/\d{1,2}\/\d{4}$/, | |
date = new Date(+p[2], +p[1] -1 , +p[0]); // dd/mm/yyy | |
return isNumber.test(data) && !(date.getDate() !== +p[0] || date.getMonth() !== (+p[1] - 1) || date.getFullYear() !== +p[2]); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf8 -*- | |
import argparse, re | |
from os import path, getcwd, mkdir, listdir, devnull | |
from subprocess import Popen | |
# valida se 'string' segue o padrão de resolução de tela. 9999x9999 ou 9999X9999 | |
def isScreenSize(string): | |
regex = re.compile(r"^\d+x\d+$", re.IGNORECASE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Bubble Sort implementado em PHP com flag se o array já estiver ordenado | |
*/ | |
function bubble_sort($arr) { | |
$flag = false; | |
while(!$flag) { | |
$flag = true; | |
for ($i=1; $i < count($arr); $i++) { |
OlderNewer