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
| app.delete('/:id', (req, res) => { | |
| const { id } = req.params; | |
| for (let i = 0; i < questions.length; i++) { | |
| const question = questions[i]; | |
| if (question.id === parseInt(id)) { | |
| questions.splice(i, 1); | |
| return res.status(200).send(); | |
| } | |
| } |
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 React from 'react'; | |
| import {Route} from 'react-router-dom'; | |
| import auth0Client from '../Auth'; | |
| function SecuredRoute({ component: Component, ...rest }) { | |
| return ( | |
| <Route {...rest} render={(props) => { | |
| if (!auth0Client.isAuthenticated()) return auth0Client.signIn(); | |
| return <Component {...props} /> | |
| }} /> |
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
| class GossipService { | |
| gossip(message: string) { | |
| console.log(message.toLowerCase()); | |
| } | |
| } | |
| export default GossipService; |
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 clientLinks = [].slice.call(document.getElementsByTagName('a')).filter(link => { | |
| const {href} = link; | |
| if (href.indexOf('manage.auth0.com') < 0) return null; | |
| if (href.indexOf('clients') > 0) return link; | |
| return 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
| # issue a POST request to get a token | |
| curl -X POST -H 'Content-Type: application/json' -d '{ | |
| username: "mario", | |
| password: "secret" | |
| }' http://localhost:63939/api/token | |
| # replace xxx.yyy.zzz with the token retrieved in the previous command | |
| JWT="xxx.yyy.zzz" | |
| # use the token to retrieve books |
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 arr1 = ['apple', 'banana']; | |
| let arr2 = [...arr1, 'watermelon']; | |
| console.log(arr1); | |
| console.log(arr2); | |
| let obj1 = { | |
| name: 'Bruno', | |
| surname: 'Krebs' | |
| } | |
| let obj2 = { |
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
| docker run --name mysql \ | |
| -p 3306:3306 \ | |
| -e MYSQL_ROOT_PASSWORD=my-password \ | |
| -e MYSQL_DATABASE=some-db-name \ | |
| -e MYSQL_USER=some-user \ | |
| -e MYSQL_PASSWORD=some-user-password \ | |
| -d mysql:5.7 | |
| docker stop mysql | |
| docker rm mysql |
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
| package com.auth0.samples.secure; | |
| import org.springframework.context.annotation.Bean; | |
| import org.springframework.context.annotation.Configuration; | |
| import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; | |
| import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | |
| import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | |
| import org.springframework.web.cors.CorsConfiguration; | |
| import org.springframework.web.cors.CorsConfigurationSource; | |
| import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
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
| alias new_post="create_new_post" | |
| function create_new_post { | |
| # are we are on blog's root dir? | |
| ls | grep Rakefile &> /dev/null \ | |
| && ls | grep _posts &> /dev/null | |
| if [ $? -gt 0 ]; then | |
| echo "not on blog's root directory" | |
| return 1 | |
| fi |
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
| const axios = require('axios'); | |
| axios.post('http://localhost:8080/login', { | |
| "username": "admin", | |
| "password": "password" | |
| }).then(function (response) { | |
| console.log(response.headers.authorization); | |
| }).catch(function (error) { | |
| console.log(error); | |
| }); |