Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View edgvi10's full-sized avatar

Eduardo Vieira edgvi10

  • Amora Sistemas, Link Informática RJ
  • Rio de Janeiro
View GitHub Profile
@edgvi10
edgvi10 / slugify.js
Last active August 25, 2020 17:39 — forked from codeguy/slugify.js
Create slug from string in Javascript
String.prototype.slugify = function (separator = "-") {
return this
.toString()
.normalize('NFD') // split an accented letter in the base letter and the acent
.replace(/[\u0300-\u036f]/g, '') // remove all previously split accents
.toLowerCase()
.trim()
.replace(/[^a-z0-9 ]/g, '') // remove all chars not letters, numbers and spaces (to be replaced)
.replace(/\s+/g, separator);
};
@edgvi10
edgvi10 / Helpers.php
Last active October 2, 2020 17:34
Some PHP Functions
<?php
namespace EDGVI10;
class Helpers
{
public static function getEnv($filepath)
{
$env = file_get_contents($filepath);
@edgvi10
edgvi10 / base64url.php
Last active October 5, 2020 06:46
PHP function to convert any string to base64 url friendly
<?php
function base64url_encode($data)
{
$base64 = base64_encode($data);
if ($base64 === false) return false;
$url = strtr($base64, '+/', '-_');
{
"uuid": "123456-123456-123456-123456-123456",
"name": "Eduardo Gomes Vieira",
"nickname": "edgvi10",
"role": "developer",
"key": "value"
}
@edgvi10
edgvi10 / QueryBuilder.php
Created January 22, 2021 23:54
Funções PHP para converter Arrays em SQL
<?php
function parseValue($value)
{
$functions = ["UUID()", "NOW()", "NULL"];
$useapostrofe = true;
if ($useapostrofe) $useapostrofe = (array_search($value, $functions) === false) ? true : false;
if ($useapostrofe) $useapostrofe = (hexdec(intval($value)) == hexdec($value)) ? false : true;
if ($useapostrofe) $useapostrofe = (hexdec(floatval($value)) == hexdec($value)) ? false : true;

INSTALL AND CONFIGURE LAMP

Install Apache and cURL.

sudo apt update

sudo apt install apache2 curl

Configure Apache Firewall

@edgvi10
edgvi10 / object-search.js
Last active March 7, 2021 10:18
Javascript Object Search
Array.prototype.search = function (keyword, options) {
const results = [];
if (options === undefined) options = {};
this.map(item => {
if (typeof item === "object") {
var keys = Object.keys(item);
if ("fields" in options)
keys = options["fields"];
@edgvi10
edgvi10 / search.js
Last active August 12, 2021 19:47
Busca por campos em Array e Object em Javascript
export const search = (list, keyword, options) => {
if (options === undefined) options = {};
if (typeof list === "object") {
const results = {};
Object.keys(list).map(item_index => {
const item = list[item_index];
if (typeof item === "object") {
var keys = Object.keys(item);
@edgvi10
edgvi10 / material-colors.css
Last active August 16, 2021 15:50
Material Colors
:root {
--md-red-50: #ffebee;
--md-red-100: #ffcdd2;
--md-red-200: #ef9a9a;
--md-red-300: #e57373;
--md-red-400: #ef5350;
--md-red-500: #f44336;
--md-red-600: #e53935;
--md-red-700: #d32f2f;
--md-red-800: #c62828;
UPDATE `produtos` SET
`CODIGO_INTERNO` = TRIM('0' FROM `CODIGO_BARRAS`),
`CODIGO_BARRA_REF` = `CODIGO_BARRAS`,
`CODIGO_FORNECEDOR` = '0001',
-- `CODIGO_LOJA` = '002',
`DATA_CAD` = DATE(NOW()),
`DATA_ALT` = DATE(NOW()),
`DATAINI_PROM` = DATE(NOW()),
`DATAFIM_PROM` = DATE(NOW()),