Skip to content

Instantly share code, notes, and snippets.

View Daniel-Sogbey's full-sized avatar
🌍
Learning

Daniel Sogbey Daniel-Sogbey

🌍
Learning
View GitHub Profile
const jwt = require("jsonwebtoken")
const User = require("../models/user")
const auth = async (req, res, next) => {
try {
const token = req.header("Authorization").replace("Bearer ", "")
const decode = jwt.verify(token, "thisismysecretkey")
const user = await User.findOne({ _id: decode._id, "tokens.token": token })
if (!user) {
@Daniel-Sogbey
Daniel-Sogbey / dynamic_link_url.txt
Created August 12, 2022 05:08
Dynamic Link URL with Firebase
import 'package:flutter/material.dart';
import '../constants/store.dart';
import '../model/directions.dart';
class AppInfo extends ChangeNotifier {
Directions? userPickupLocation, userDropOffLocation;
updatePickupLocationAddress(Directions userPickupAddress) {
userPickupLocation = userPickupAddress;
import 'package:flutter/material.dart';
import '../constants/store.dart';
import '../model/directions.dart';
class AppInfo extends ChangeNotifier {
Directions? userPickupLocation, userDropOffLocation;
updatePickupLocationAddress(Directions userPickupAddress) {
userPickupLocation = userPickupAddress;
// method in a widget that inherits stateful widget
Future<void> _refreshFoo(BuildContext context) async {
// First category: Foo
await Provider.of<Foo>(context, listen: false)
.fetchFoo(true);
//Second category: Bar
await Provider.of<Bar>(context, listen: false)
.fetchBar(true);
}
@Daniel-Sogbey
Daniel-Sogbey / jsonToModel.dart
Created August 21, 2023 12:27
Cast JSON to Model instances
import "dart:convert";
void main() {
var rawJson = '{"url":"http://blah.jpg", "id":1}';
var parsedJson = json.decode(rawJson);
var imageModel = ImageModel.fromJson(parsedJson);
}