Skip to content

Instantly share code, notes, and snippets.

@SrPhilippe
Last active June 6, 2018 01:50
Show Gist options
  • Save SrPhilippe/40b239dd545c15d05d0be35183e75c05 to your computer and use it in GitHub Desktop.
Save SrPhilippe/40b239dd545c15d05d0be35183e75c05 to your computer and use it in GitHub Desktop.
Programming stuffs
    let element = document.querySelector("selector");

scroll animation to the anchor

let $doc = $("html, body");
$(".scroll").click(function(e) {
  $doc.animate({
    scrollTop: $( $.attr(this, "href") ).offset().top
  }, 500);
  e.preventDefault();
});

Shorhand if else

let age = 14;
let minAge = 18;

// The shorthand
(age >= minAge) ? console.log("Your account was created") : console.log("You don't have enough age to enter");

Easy way to reset timer js

let secounds = 5;
let timer = () => {
  interval = setInterval(nextSlider, segundos * 1000);
};

// starting the timer
timer();

// cleaning the timer
clearInterval(interval);

Logic to beauty animation contact form on keyup

$("#contato form input").each((i, el) => {
  $(el).on("keyup", () => {
    let keyL = $(el).val().length;
    if (keyL > 0) {
      $(el).addClass("active");
      $(el).prev("p.info-input").addClass("active");
    } else {
      $(el).removeClass("active");
      $(el).prev("p.info-input").removeClass("active");
    } // end else
  });
});

Script to remove watermark from 000webhost

// Script para ocultar marca d'agua 000webhost
$("div[style='text-align: right;position: fixed;z-index:9999999;bottom: 0; width: 100%;cursor: pointer;line-height: 0;display:block !important;']").css("display", "none");

Reset table's auto increment

ALTER TABLE tablename AUTO_INCREMENT = 1
# This function bellow redirect the user to the following link if the user try to access a directory or file that doesn't exist.
ErrorDocument 404 https://(link here)/

# This whole block of code removes the .html to the link
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]

# sets the max_filesize and post_max_size
php_value upload_max_filesize 500M
php_value post_max_size 500M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment