This file contains 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 is a custom made Python function/method I made that accepts an array value and calculates the variance | |
def variance(array_value): | |
sum = 0 | |
for i in array_value: | |
sum += i | |
mean = sum / len(array_value) | |
difference_value = 0 | |
for j in array_value: |
This file contains 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 arrayOfNumbers = ['BOB778','KEK7899','FOR4442','KIMP889']; | |
const numberValues = arrayOfNumbers.map(item => item.match(/\d+/)[0]); | |
const sumOfNumbers = numberValues.reduce((total, num) => Number(total) + Number(num)); | |
// sumOfNumbers = 14008 [778 + 7899 + 4442 + 889] |
This file contains 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
// an absctract representation | |
class Person { | |
constructor(name,email) { | |
this.name = name | |
this.email = email | |
} | |
// things a person can do (functions/methods within a class) | |
sayName() return `My name is ${this.name}`; | |
emailAddress() return this.email; |
This file contains 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 express = require('express'); | |
const router = express.Router(); | |
const { verifyJWToken } = require("../utils/authUtils"); | |
const OrderController = require("../controllers/order.controller"); | |
router.post("/remove", verifyJWToken, OrderController.deleteOrder); | |
router.post("/confirm", verifyJWToken, OrderController.confirmDelivery); | |
router.post("/cancel", verifyJWToken, OrderController.cancelDelivery); |
This file contains 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 { sign, verify } = require("jsonwebtoken"); | |
module.exports = { | |
verifyJWToken(req, res, next) { | |
if (req.headers.authorization) { | |
const token = req.headers.authorization.split(" ")[1]; | |
verify(token, 'secretword', { complete: true }, (error, decoded) => { | |
if (error) { res.json({ ok: false, error }) } | |
if (decoded ) { next() } | |
}); |
This file contains 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 express = require('express') | |
const BusBoy = require('busboy') | |
const path = require('path') | |
const os = require('os') | |
const fs = require('fs') | |
const app = express() | |
app.post('/', (req, res) => { | |
const busboy = new BusBody({ headers: req.headers }) |
This file contains 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
mounted() { | |
// call methods when component is done "mounting" :wink: | |
this.getUserLocation(); | |
this.trackUserLocation(); | |
}, | |
methods: { | |
getUserLocation() { | |
// get user position | |
window.navigator.geolocation.getCurrentPosition((position) => { | |
const { latitude, longitude } = position.coords; |
This file contains 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 { Component } from '@angular/core'; | |
@Component({ | |
selector: 'app-login', | |
templateUrl: 'app-login.html', | |
styleUrls: ['styles.css'], | |
}) | |
export class AppLogin { | |
constructor() { } |
This file contains 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 { Component, OnInit } from '@angular/core'; | |
import StateService from '../services/state.service.ts'; | |
@Component({ | |
selector: 'app-change-state', | |
template: ` | |
<div> | |
<div> {{username }} </div> | |
<input [(ngModel)]="username" placeholder="enter username" /> | |
<button (click)="updateUsername()"></button> |
This file contains 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 Injectable from '@angular/core'; | |
import { BehaviorSubject } from 'rxjs/BehaviorSubject'; | |
@Injectable() | |
export class StateService { | |
private usernameSource = new BehaviorSubject<string>('Onejohi Tony'); | |
username = this.usernameSource.asObservable() | |
constructor() { } |
NewerOlder