Skip to content

Instantly share code, notes, and snippets.

View Bilguun132's full-sized avatar

Batbold Bilguun Bilguun132

View GitHub Profile
@Bilguun132
Bilguun132 / ChatsViewController.swift
Created March 23, 2019 09:31
iOS-Tutorial-FakeChat-ChatsViewController
//
// ChatsViewController.swift
// FakeChat
//
// Created by Bilguun Batbold on 23/3/19.
// Copyright © 2019 Bilguun. All rights reserved.
//
import UIKit
@Bilguun132
Bilguun132 / ChatMessageCell.swift
Last active March 23, 2019 10:41
iOS-Tutorial-FakeChat-ChatMessageCell
//
// ChatMessageCell.swift
// FakeChat
//
// Created by Bilguun Batbold on 23/3/19.
// Copyright © 2019 Bilguun. All rights reserved.
//
import Foundation
import UIKit
@Bilguun132
Bilguun132 / ViewController.swift
Last active March 23, 2019 06:21
iOS-Tutorial-FakeChat-ViewController-1
//
// ViewController.swift
// FakeChat
//
// Created by Bilguun Batbold on 23/3/19.
// Copyright © 2019 Bilguun. All rights reserved.
//
import UIKit
import NotificationCenter
@Bilguun132
Bilguun132 / scraper-github-trending.py
Created March 21, 2019 15:15
python-scraping-tutorial-github-trending_3
@Bilguun132
Bilguun132 / scraper-github-trending.py
Created March 21, 2019 15:02
python-scraping-tutorial-github-trending_2
@Bilguun132
Bilguun132 / scraper-github-trending.py
Created March 21, 2019 14:41
python-scraping-tutorial-github-trending
@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 / 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 / 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.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,