Skip to content

Instantly share code, notes, and snippets.

View lenivene's full-sized avatar
🖖
Full-stack dev

Lenivene Bezerra lenivene

🖖
Full-stack dev
View GitHub Profile
[General]
disabledTrayIcon=false
filenamePattern=%j%A%M%S%H_screenshot
@lenivene
lenivene / UUID.function.php
Created October 26, 2019 16:08
Unique IDentifiers
<?php
function UUID(){
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0x0fff) | 0x4000,
mt_rand(0, 0x3fff) | 0x8000,
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
}
@lenivene
lenivene / Alert.js
Created October 23, 2019 16:04
A CONTROLLER TO ALERTS USING SWEETALERT
import Swal from "sweetalert2";
export default {
success: function(options, callback) {
if ("string" == typeof options) {
options = { title: options };
}
var settings = Object.assign(
{},
@lenivene
lenivene / cross-origin.js
Created September 30, 2019 22:08
Node JS: Adds CORS ( Cross-origin resource sharing ) headers to the response
/**
* Adds CORS ( Cross-origin resource sharing ) headers to the response
*
* @param {object} request the Request object
* @param {object} response the Response object
* @param {function} next function to continue execution
*
* @return {void}
*/
module.exports = ( request, response, next ) => {
<div class="components__Loader"></div>
@lenivene
lenivene / code.php
Last active September 27, 2019 03:27
Get boolean false or true in value.
<?php
if( ! defined( 'FILTER_VALIDATE_BOOLEAN' ) ){
define( 'FILTER_VALIDATE_BOOLEAN', 258 );
}
$db_value = 1;
$bool_value = filter_var( $db_value, FILTER_VALIDATE_BOOLEAN );
var_dump( $bool_value );
@lenivene
lenivene / array_sort_by_column.php
Created September 16, 2019 14:00
Array sort by column
<?php
/**
* Array sort by column
*
* @author Lenivene
* @param array List
* @param string|array Columns name or single column
* @param int Order BY ASC|DESC.
* I recommend you use constant, Ex: SORT_ASC = 4 ( int ) | SORT_DESC = 3 ( int )
*/
@lenivene
lenivene / hierarchy_tree.php
Last active September 16, 2019 14:03
PHP: Create a array tree from array list
<?php
/**
* Create a array tree from array list
*
* @param array ( Required ) The list to create tree
* @param string The name key parent. Ex: parent_id
* @param string The key to check child. Ex: ID
*
* @return array|false Returns array if the date given is not empty; otherwise returns FALSE.
*/
@lenivene
lenivene / Pluck.js
Last active September 16, 2019 14:02
A simple pluck function.
module.exports = (object, ...keys) => {
const newObject = {};
keys.forEach(key => newObject[key] = object[key])
return newObject;
}
<?php
function count_months_in_time( $timestamp ){
$time_now = time();
$months = ( ( ( date( 'Y', $timestamp ) - date( 'Y', $time_now ) ) * 12 ) + ( date( 'm', $timestamp ) - date( 'm', $time_now ) ) );
return $months;
}
echo count_months_in_time( strtotime( date( '09/08/2019' ) ) );