Skip to content

Instantly share code, notes, and snippets.

View Bilguun132's full-sized avatar

Batbold Bilguun Bilguun132

View GitHub Profile
@Bilguun132
Bilguun132 / main.dart
Created March 15, 2019 16:18
crypto_list-FlutterDemo-main-4
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 {
@Bilguun132
Bilguun132 / main.dart
Created March 15, 2019 16:28
crypto_list-FlutterDemo-main-5
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 {
@Bilguun132
Bilguun132 / main.dart
Created March 15, 2019 16:35
crypto_list-FlutterDemo-getMainBody
_getMainBody() {
if (_loading) {
return new Center(
child: new CircularProgressIndicator(),
);
} else {
return new RefreshIndicator(
child: _buildCryptoList(),
onRefresh: getCryptoPrices,
);
@Bilguun132
Bilguun132 / main.dart
Created March 15, 2019 16:44
crypto_list-FlutterDemo-pushSaved
//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']),
@Bilguun132
Bilguun132 / user.model.js
Last active October 22, 2019 05:08
nodejs-auth-Tutorial-usermodel
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,
@Bilguun132
Bilguun132 / auth.js
Last active March 18, 2019 13:04
nodejs-auth-Tutorial-auth.js
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 {
@Bilguun132
Bilguun132 / user.route.js
Created March 18, 2019 13:25
nodejs-auth-Tutorial-userroute
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);
});
@Bilguun132
Bilguun132 / index.js
Created March 18, 2019 13:32
nodejs-auth-Tutorial-index.js
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.");
@Bilguun132
Bilguun132 / scraper-github-trending.py
Created March 21, 2019 14:41
python-scraping-tutorial-github-trending
@Bilguun132
Bilguun132 / scraper-github-trending.py
Created March 21, 2019 15:02
python-scraping-tutorial-github-trending_2