Skip to content

Instantly share code, notes, and snippets.

View MrXploder's full-sized avatar

Luis Arancibia MrXploder

View GitHub Profile
@MrXploder
MrXploder / nthDayOfMonth.php
Created May 22, 2018 04:04
PHP Function to find the "nth" (first, second, third, fourth, fifth) day of the given day, month and year.
<?php
/*
* @params $nbr (number) -> first, second, third or fourth day of month
* @params $day (string) -> name of the day in the week
* @params $mon (number) -> number of the month to seach
* @params $year (number) -> number of the year to search
* @author MrXploder
*/
function nth_day_of_month($nbr, $day, $mon, $year){
@MrXploder
MrXploder / randomKey.php
Created May 22, 2018 04:08
PHP Function to return a random alphanumeric token given the desired length
<?php
/*
* @params $length (number) -> length of the random alphanumeric token
* @author MrXploder
*/
function randomKey($length) {
$pool = array_merge(range(0,9), range('a', 'z'),range('A', 'Z'));
for($i=0; $i < $length; $i++) {
@MrXploder
MrXploder / sanitizeInput.php
Created May 22, 2018 04:10
PHP Function to sanitize a GET variable
<?php
/*
* @param $data (variable) -> can be any valid type
* @author MrXploder
*/
function sanitizeInput($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
@MrXploder
MrXploder / modal.factory.js
Last active May 26, 2018 06:06
MaterializeCSS (v0.100.2) Modal Factory for AngularJS (1.6.6 Tested)
/*USAGE: YOU CAN OPEN A MODAL FROM A CONTROLLER
(function(){
angular
.module("myModule")
.controller("myController", myController)
myController.$inject = ["Modal", "$scope"];
function myController(Modal, $scope){
var vm = this;
@MrXploder
MrXploder / tooltip.js
Created June 30, 2018 21:08
MaterializeCSS Tooltip - Color Option
(function ($) {
$.fn.tooltip = function (options) {
var timeout = null,
margin = 5;
// Defaults
var defaults = {
delay: 350,
tooltip: '',
position: 'bottom',
<!DOCTYPE html>
<html>
<head>
<title>Simple JavaScrip Test</title>
</head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<style type="text/css">
</style>
<body>