Skip to content

Instantly share code, notes, and snippets.

View MiguelQueiroz's full-sized avatar
🏠
Working from home

Miguel Queiroz MiguelQueiroz

🏠
Working from home
View GitHub Profile
@eresende
eresende / nif-pt.js
Last active April 11, 2024 15:49
Validação de NIF Portugal com Javascript
/*
Source: http://www.portugal-a-programar.pt/topic/58852-algoritmo-de-validacao-de-nif-pt/
*/
function validaContribuinte(contribuinte){
// algoritmo de validação do NIF de acordo com
// http://pt.wikipedia.org/wiki/N%C3%BAmero_de_identifica%C3%A7%C3%A3o_fiscal
var temErro=0;
@a-r-m-i-n
a-r-m-i-n / precise_round.js
Created January 28, 2015 14:43
How to round correctly in JavaScript
function sign(num) {
// IE does not support method sign here
if (typeof Math.sign === 'undefined') {
if (num > 0) {
return 1;
}
if (num < 0) {
return -1;
}
return 0;
anonymous
anonymous / gist:8216423
Created January 2, 2014 08:31
Cookie law
<div id="c_cookie_alert_div" style="color:red;background-color: rgba(216, 209, 209, 0.63);color: white;/* width: 100%; */margin: -8px 20%;/* padding: 9px; */font-size: small; cursor:default; text-align: center;font-family: tahoma, verdana;">
By using our website you are accepting to store cookies information which help us to deliver you a better experience. You can clear this website cookies on your browser settings <span style="cursor:pointer;" onclick="c_cookie_alert_div_r()">[X]</span>
</div>
<script>function c_cookie_alert_div_r(){document.getElementById("c_cookie_alert_div").innerHTML="";}</script>
@MiguelQueiroz
MiguelQueiroz / mini_pic_slide.js
Last active December 31, 2015 10:28
This jQuery plugin, will extend img capabilities, by creating a slide gallery effect based on a comma separated src of images. Just simple call it and you are ready to go.
//Miguel Queiroz - 2013
// A call to the jQuery lib is required.
//Converts a img element into a gallery, transitioning between pictures when loaded. Based on a string src.
/// Like: $("#img_div").pic_slide("img1.jpg, img2.png, img3...");
(function($){
$.fn.pic_slide=function(src,path){
return this.each(function(){
var span_go="";
if(src.split(",").length<2){ $(this).attr("src",""); $(this).attr("src",src).load(function(e){$(this).fadeTo(1200,1);}); return;} //case single item