Skip to content

Instantly share code, notes, and snippets.

View boardwallfloor's full-sized avatar
:)

Faris Takhassuna Zamzani boardwallfloor

:)
  • 12:54 (UTC +07:00)
View GitHub Profile
@boardwallfloor
boardwallfloor / stopwatch.js
Created July 22, 2021 23:04
A stopwatch implementation in Javascript
function Stopwatch(){
let startTime
let isRunning = false
let endTime
this.start = function(){
if(isRunning === true){
console.log('Stopwatch already running')
}else{
startTime = new Date()
isRunning = true
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const FormGroupSchema = new Schema({
userid: {type: Schema.Types.ObjectId, ref:'User', required:true},
formid: {type: Schema.Types.ObjectId, ref:'Form', default: null},
status: {type: Boolean, default: false, required: true}
})
const TestSchema = new Schema({
@boardwallfloor
boardwallfloor / Error
Created June 1, 2020 06:26
CORS error at login
Chrome
Access to fetch at 'http://localhost:9000/login' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'localhost:3000/#/login' that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Firefox
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:9000/login. (Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘localhost:3000/#/login’).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:9000/login. (Reason: CORS request did not succeed).
const LocalStrategy = require('passport-local').Strategy;
const bcrypt = require('bcryptjs');
const User = require('../models/user');
function initialize(passport, getUserById) {
const getUserByUsername = async function(username){
User.find({username:username}).exec(function(err, results){
if(err){return next(err);}
const Player = (name, age) =>{
const getName = () => name;
const getAge = () => age;
return {getName, age};
};
const gameBoard = ( () =>{
let currentPlayer = "";
let allPlayer = [];
let board = [];