Skip to content

Instantly share code, notes, and snippets.

View knoonrx's full-sized avatar
🎯
Focusing

Rodrigo Brandão knoonrx

🎯
Focusing
View GitHub Profile
@knoonrx
knoonrx / CryptoJSAES.php
Last active January 7, 2022 18:32
CryptoJS.AES.encrypt to PHP - PHP implementation to Encrypt and decrypt a string compatible with crypto-js library AES default settings
class CryptoJSAES
{
public function encrypt($passphrase, $data, $salt = null): string
{
$salt = $salt ?: openssl_random_pseudo_bytes(8);
[$key, $iv] = $this->_evpKDF($passphrase, $salt);
$ct = openssl_encrypt($data, 'aes-256-cbc', $key, true, $iv);
return $this->_encode($ct, $salt);
}
@knoonrx
knoonrx / firebase-message
Created November 28, 2020 05:30 — forked from Albejr/firebase-message
Localize Firebase error messages in PT-BR
catchError(err => {
const errorCode = err.code;
let errorMessage = this.VerifyErroCode(errorCode);
if (errorMessage == null) {
errorMessage = err.message;
}
console.log(errorMessage);
})
@knoonrx
knoonrx / javascript.spread.ts
Last active May 1, 2019 19:42
Use the spread operator to remove duplicates items and to sort a array of numbers and objects, without destruct the original array.
// define the array of numbers and objects
const array = [{
nome: 'joão',
idade: 14
},{
nome: 'joão',
idade: 14
},7,9,8,5,15,3,9,8,6];
// remove duplicate numbers only, items of type object are not affected
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">
<title>XLSX Reader JS</title>
<link rel="stylesheet" href="screen.css" media="screen">
</head>
<body>
@knoonrx
knoonrx / storyline.html
Last active July 14, 2016 13:54
Responsive HTML + CSS + Bootstrap storyline
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Title</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<style>
.col-sm-2 {
padding: 0 !important;
@knoonrx
knoonrx / menu-justify.html
Created May 15, 2016 13:03
Materialize.css framework menu justify
<html>
<style>
/*menu justify*/
.menu-justified {
width: 100%;
}
.menu-justified>li {
float: none;
}
.menu-justified>li>a {
@knoonrx
knoonrx / checkddd.js
Last active May 11, 2016 19:49
Verifica se o ddd passado por parâmetro é válido (existe) ou não.
function pegaDDD(ddd) {
return parseInt(ddd.substr(1, 2));
}
function inArray(ddd) {
var dddArray = [11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 24, 27, 28, 31, 32, 33, 34, 35, 37, 38, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, 53, 54, 55, 61, 62, 63, 64, 65, 66, 67, 68, 69, 71, 73, 74, 75, 77, 79, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99];
return dddArray.indexOf(ddd) != -1;
}
<?php
$date_expire = '2016-04-16';
$date = new DateTime($date_expire);
$now = new DateTime();
//echo $date->diff($now)->format("%d days, %h hours and %i minuts");
//$time = $date->diff($now)->format("%d");
//echo $time;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>teste</title>
<style>
ul {
list-style: none;
-moz-column-count: 4;
-moz-column-gap: 20px;
@knoonrx
knoonrx / index.php
Created April 3, 2016 16:10
Simple Materialize css template menu for wordpress
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php bloginfo('name') ?></title>
<link type="text/css" rel="stylesheet" href="<?= get_template_directory_uri(); ?>/css/materialize.min.css" media="screen,projection">
<link type="text/css" rel="stylesheet" href="<?= get_template_directory_uri(); ?>/style.css">
<style>