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 'package:flutter/material.dart'; | |
| import 'dart:math'; | |
| import 'dart:async'; | |
| import 'dart:convert'; | |
| import 'dart:core'; | |
| import 'package:http/http.dart' as http; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { |
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 'package:flutter/material.dart'; | |
| import 'dart:math'; | |
| import 'dart:async'; | |
| import 'dart:convert'; | |
| import 'dart:core'; | |
| import 'package:http/http.dart' as http; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { |
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
| _getMainBody() { | |
| if (_loading) { | |
| return new Center( | |
| child: new CircularProgressIndicator(), | |
| ); | |
| } else { | |
| return new RefreshIndicator( | |
| child: _buildCryptoList(), | |
| onRefresh: getCryptoPrices, | |
| ); |
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
| //called when the button is pressed to go to the next view | |
| void _pushSaved() { | |
| Navigator.of(context).push( //get the current navigator | |
| new MaterialPageRoute<void>( //A modal route that replaces the entire screen with a platform-adaptive transition. | |
| builder: (BuildContext context) { | |
| final Iterable<ListTile> tiles = _saved.map( //iterate through our saved cryptocurrencies sequentially | |
| (crypto) { | |
| return new ListTile( //same list tile as what we have shown in the previous page | |
| leading: _getLeadingWidget(crypto['name'], Colors.blue), | |
| title: Text(crypto['name']), |
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 config = require('config'); | |
| const jwt = require('jsonwebtoken'); | |
| const Joi = require('joi'); | |
| const mongoose = require('mongoose'); | |
| //simple schema | |
| const UserSchema = new mongoose.Schema({ | |
| name: { | |
| type: String, | |
| required: true, |
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 jwt = require("jsonwebtoken"); | |
| const config = require("config"); | |
| module.exports = function(req, res, next) { | |
| //get the token from the header if present | |
| const token = req.headers["x-access-token"] || req.headers["authorization"]; | |
| //if no token found, return response (without going to the next middelware) | |
| if (!token) return res.status(401).send("Access denied. No token provided."); | |
| try { |
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 auth = require("../middleware/auth"); | |
| const bcrypt = require("bcrypt"); | |
| const { User, validate } = require("../models/user.model"); | |
| const express = require("express"); | |
| const router = express.Router(); | |
| router.get("/current", auth, async (req, res) => { | |
| const user = await User.findById(req.user._id).select("-password"); | |
| res.send(user); | |
| }); |
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 config = require("config"); | |
| const mongoose = require("mongoose"); | |
| const usersRoute = require("./routes/user.route"); | |
| const express = require("express"); | |
| const app = express(); | |
| //use config module to get the privatekey, if no private key set, end the application | |
| if (!config.get("myprivatekey")) { | |
| console.error("FATAL ERROR: myprivatekey is not defined."); |
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 requests | |
| from bs4 import BeautifulSoup | |
| page = requests.get('https://github.com/trending') | |
| # Create a BeautifulSoup object | |
| soup = BeautifulSoup(page.text, 'html.parser') | |
| # get the repo list |
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 requests | |
| from bs4 import BeautifulSoup | |
| page = requests.get('https://github.com/trending') | |
| # Create a BeautifulSoup object | |
| soup = BeautifulSoup(page.text, 'html.parser') | |
| # get the repo list |