Será?
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 | |
date_default_timezone_set('America/Sao_Paulo'); // CHANGE: timezone | |
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); | |
socket_connect($sock, "8.8.8.8", 53); | |
socket_getsockname($sock, $localAddr); // now the $localAddr will have the machine ip | |
$dirs = array_filter(glob('*'), 'is_dir'); | |
?> |
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
// Local Storage with fallback in memory | |
class CustomStorage | |
{ | |
fallbackStorage = {}; | |
isLocalAvailable = false; | |
prefix = ''; | |
constructor(prefix) { | |
this.isLocalAvailable = this.isStorageAvailable(); |
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
{% macro list(items, class) %} | |
<ul class="{{class}}"> | |
{# Iterating over each direct items #} | |
{% for item in items %} | |
<li> | |
<a href="">{{item.name}}</a> | |
{# If an item has children #} | |
{% if item.children %} |
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
{ | |
} |
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
public function promiseWithTimeout(something, maxTime) { | |
let timeout = new Promise ((resolve, reject) => { | |
let counter = setTimeout(() => { | |
clearTimeout(counter); | |
reject('TIMEOUT'); | |
}, maxTime) | |
}); | |
return Promise.race([ | |
something, |
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
numberToReal(numero) { | |
if (isNaN(numero)) { | |
return ''; | |
} | |
numero = Number(numero).toFixed(2).split('.'); | |
numero[0] = numero[0].split(/(?=(?:...)*$)/).join('.'); | |
return numero.join(','); | |
} |
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
formatDateString(string) { | |
let fullDate = string.split(" "); | |
let day = fullDate[0]; | |
let time = fullDate[1]; | |
day = day.split("/"); | |
return (day[2] + "-" + day[1] + "-" + day[0] + "T" + time); | |
} |
NewerOlder