This file contains hidden or 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
// JSON WEB TOKEN | |
// A JSON Web Token (JWT) is a JSON object that is defined in RFC 7519 as a safe way to represent a set of information between two parties. The token is composed of a header, a payload, and a signature. | |
// Formula: | |
data = base64urlEncode( header ) + “.” + base64urlEncode( payload ) | |
signature = Hash( data, secret ); | |
// Standard fields: | |
// Issuer (iss) - identifies principal that issued the JWT; |
This file contains hidden or 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
// iniciar composer e criar composer.json | |
composer init | |
// instalar dependecias | |
composer require nomeda/dependencia || composer require-dev nomeda/dependencia | |
composer install || composer update | |
// dump dos autoloads | |
composer dumpautoload |
This file contains hidden or 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
// JS | |
Vue.component('child', { | |
// camelCase in JavaScript | |
props: ['myMessage'], | |
template: '<span>{{ myMessage }}</span>' | |
}) | |
// HTML | |
<!-- kebab-case in HTML --> <child my-message="hello!"></child> |
This file contains hidden or 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 will render the same result. We can also bind to a computed property that returns an object. This is a common and powerful pattern: | |
// HTML | |
<div v-bind:class="classObject"></div> | |
// JS | |
data: { | |
isActive: true, error | |
: | |
null | |
} |
This file contains hidden or 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
var obj = { | |
name: 'John Doe', | |
greet () { | |
console.log(`Hey ${this.name}`); | |
} | |
}; | |
obj.greet(); // Hey John Doe |
This file contains hidden or 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
// Emitter.js | |
// function constructor for event | |
function Emitter() { | |
this.events = {}; | |
} | |
// prototype method to add listener (array of functions) | |
Emitter.prototype.on = function (type, listener) { | |
this.events[type] = this.events[type] || []; | |
this.events[type].push(listener); |
This file contains hidden or 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
$url = 'http://server.com/path'; | |
$data = array('key1' => 'value1', 'key2' => 'value2'); | |
// use key 'http' even if you send the request to https://... | |
$options = array( | |
'http' => array( | |
'header' => "Content-type: application/x-www-form-urlencoded\r\n", | |
'method' => 'POST', | |
'content' => http_build_query($data) | |
) |
This file contains hidden or 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 | |
$path ='/dir0/dir1/myfile.php'; | |
$file = 'file1.txt'; | |
// Return filename | |
echo basename($path); | |
// Return filename without ext | |
echo basename($path, '.php'); |
This file contains hidden or 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
import Vue from "vue" | |
import App from "./App.vue"; | |
import VueRouter from "vue-router"; | |
import User from "./components/user/User.vue"; | |
import Home from './components/Home.vue'; | |
Vue.use(VueRouter); | |
const router = new VueRouter( | |
{ |
This file contains hidden or 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
///////////////////////////////////////// | |
// Let e const sao block scoped | |
{ | |
let a = 2; | |
const b = "Hey"; | |
console.log(a,b); | |
} | |
///////////////////////////////////////// |