This file contains hidden or 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 {ipcMain} = require('electron'); | |
| const db = require('../../db.js'); | |
| ipcMain.on('login-auth', (event,data) => { | |
| console.log('data passed from login component', data); | |
| // authentication is to generate hashvalue in bcrypt and check if the password exist | |
| // however when the user close and get back in, they need to sign in again | |
| // do authentication here | |
| db.user.authenticate(data).then((user) => { | |
| console.log('user here in login-async after authenticating',data); |
This file contains hidden or 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 Sequelize = require('sequelize'); | |
| const sequelize = new Sequelize(undefined, undefined, undefined, { | |
| 'dialect':'sqlite', | |
| 'storage': __dirname + '/data/dev-product.sqlite' | |
| }); | |
| let db = {}; | |
This file contains hidden or 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 TeamForm = () => { | |
| return ( | |
| <> | |
| <label htmlFor="admins">Team Name</label> | |
| <input type="text" value={team.name} onChange={handleChange} name={'name'} placeholder="Team Name" /> | |
| <div> | |
| <label htmlFor="admins">Admins</label> | |
| <select name={"admins"} value={''} onChange={handleChange}> | |
| {usernameList.map(({id, username}) => | |
| <option key={uuid.v4()} value={id}>{username}</option> |
This file contains hidden or 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
| def division(num1:Int, num2:Int): Either[Exception, Int] = if(num2 == 0) { | |
| Left(new IllegalStatement("num1 cannot divide by zero")) | |
| } else { | |
| Right(num1/num2) | |
| } |
This file contains hidden or 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
| def unfold[A,S](s:S)(f: S => Option[(A,S)]): List[A] = f(s) match { | |
| case Some((currentResult,nextState)) => currentResult :: unfold(nextState)(f) | |
| case None => Nil | |
| } |
This file contains hidden or 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
| sealed trait Graph[+T] | |
| case class Node[T](value:T, child:List[Graph[T]]) extends Graph[T] | |
| def bfs[T](root:Graph[T]): List[T] = | |
| unfold(List(root)){ | |
| case Node(value,child) :: t => | |
| val newQueue = t ++ child | |
| Some((value, newQueue)) | |
| case Nil => None |
This file contains hidden or 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
| def fib(n:Int): Int = generateFibSequence(n).last | |
| def generateFibSequence(n:Int): List[Int] = | |
| unfold((n, (0,1))){s => s match { | |
| case ((num, (f0, f1))) if(num > 0) => Some((f0, (num -1, (f1, f0+f1)))) | |
| case _ => None // terminate | |
| }} |
This file contains hidden or 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
| def factorialGenerator(n:Int): List[Int] = unfold((1, 1)){ | |
| case ((num,_)) if (num > n) => None | |
| case ((num, currFactorial)) => | |
| val nextFactorialValue = currFactorial * num | |
| Some(( nextFactorialValue, (num+1, nextFactorialValue))) | |
| } |
This file contains hidden or 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
| def and(a: () => Boolean, b: () => Boolean): Boolean = if(!a()) { | |
| false | |
| } else if(!b()) { | |
| false | |
| } else { | |
| true | |
| } |
This file contains hidden or 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
| def and(a: => Boolean, b: => Boolean): Boolean = | |
| if(!a) { | |
| false | |
| } else if(!b) { | |
| false | |
| } else { | |
| true | |
| } |
OlderNewer