Skip to content

Instantly share code, notes, and snippets.

View atakangah's full-sized avatar

Andrews Kangah atakangah

View GitHub Profile
@atakangah
atakangah / editroute_1.js
Last active July 12, 2020 11:00
An express routing js file to take a student's Id and a course Id from a request body to the api server and remove the associated course with the specified course Id from the student's courses list
router.post('/complete-student-course', async (req, res) => {
let {studentId, courseId} = req.body;
@atakangah
atakangah / editroute_2.js
Created July 12, 2020 11:01
<<Continuation>>An express routing js file to take a student's Id and a course Id from a request body to the api server and remove the associated course with the specified course Id from the student's courses list<<Continuation>>
try {
let student = await Students.find({ 'studentId': studentId }).exec();
/*
* After finding the student with the provided studentId,
* Use O(n) algorithm to find the course to complete for student
* It is unlikely for any student to have more than 5 courses in its course list at aytime
* Therefore, O(n) algorithm is ok
*/
@atakangah
atakangah / editroute_3.js
Last active July 12, 2020 11:08
<<Continuation>>An express routing js file to take a student's Id and a course Id from a request body to the api server and remove the associated course with the specified course Id from the student's courses list<<Continuation>>
// Update student data with new data without the deleted course
try {
let ccompleteRes = await Students.updateOne({ 'studentId': studentId }, student[0], { upsert: true }).exec();
/*
* NOTICE THE CALL TO THIS FUNCTION
* I DID NOT USE AWAIT
*/
updateCompletedStudents(courseId, student, res);
async function updateCompletedStudents(courseId, student, res) {
/*
* Substract -1 from @continuingStudents on system
*/
try {
//Get current system data
let system = await System.find({ 'systemId': SYSTEM_ID }).exec();
@atakangah
atakangah / async_demon.js
Created July 12, 2020 11:44
This shows fixes in async demons
router.post('/complete-student-course', async (req, res) => {
let {studentId, courseId} = req.body;
@atakangah
atakangah / async_demon_2.js
Created July 12, 2020 11:45
This shows fixes in async demon 2
async function updateCompletedStudents(courseId, student, res) {
/*
* Substract -1 from @continuingStudents on system
*/
@atakangah
atakangah / await_demon_1.js
Last active July 12, 2020 11:49
This shows fixes on await demon 1
// Update student data with new data without the deleted course
try {
let ccompleteRes = await Students.updateOne({ 'studentId': studentId }, student[0], { upsert: true }).exec();
@atakangah
atakangah / await_demon_2.js
Created July 12, 2020 11:50
This shows fixes on await demon 2
try {
//Update new system status
await System.updateOne({ 'systemId': SYSTEM_ID }, system[0], { upsert: true }).exec();
@atakangah
atakangah / debugging_1.js
Created July 12, 2020 12:18
Shows debugging database calls
//Update new system status
let updateResult = await System.updateOne({ 'systemId': SYSTEM_ID }, system[0], { upsert: true }).exec();
console.log('Update Result:', updateResult);
@atakangah
atakangah / README.md
Created June 4, 2021 14:29 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store