Skip to content

Instantly share code, notes, and snippets.

Avatar

Eduardo Vieira edgvi10

  • Amora Sistemas, Link Informática RJ
  • Rio de Janeiro
View GitHub Profile
@edgvi10
edgvi10 / slugify.js
Last active Aug 25, 2020 — forked from codeguy/slugify.js
Create slug from string in Javascript
View slugify.js
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 Oct 2, 2020
Some PHP Functions
View Helpers.php
<?php
namespace EDGVI10;
class Helpers
{
public static function getEnv($filepath)
{
$env = file_get_contents($filepath);
@edgvi10
edgvi10 / base64url.php
Last active Oct 5, 2020
PHP function to convert any string to base64 url friendly
View base64url.php
<?php
function base64url_encode($data)
{
$base64 = base64_encode($data);
if ($base64 === false) return false;
$url = strtr($base64, '+/', '-_');
View user.json
{
"uuid": "123456-123456-123456-123456-123456",
"name": "Eduardo Gomes Vieira",
"nickname": "edgvi10",
"role": "developer",
"key": "value"
}
@edgvi10
edgvi10 / QueryBuilder.php
Created Jan 22, 2021
Funções PHP para converter Arrays em SQL
View QueryBuilder.php
<?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;
View LAMP.md

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 Mar 7, 2021
Javascript Object Search
View object-search.js
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 Aug 12, 2021
Busca por campos em Array e Object em Javascript
View search.js
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);
View material-colors.css
: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;
View gist:089509b7cedff28f7bc124f5cf11c2a6
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()),