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
function getColors(code) { | |
const array = code.split('') | |
const [r,g,b] = [[array[1],array[2]],[array[3],array[4]],[array[5],array[6]]] | |
return { | |
red: parseInt(r.join(''), 16), | |
green: parseInt(g.join(''), 16), | |
blue: parseInt(b.join(''), 16), | |
} | |
} | |
console.log(getColors("#FF9933")); |
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
function createSieve(length) { | |
// @ts-ignore | |
var sieve = new Array(length).fill(-1); | |
for (var i = 1; i < length; i++) { | |
var number = i + 1; | |
if (sieve[i] === -1) { | |
for (var j = i + number; j < length; j += number) { | |
if (sieve[j] === -1) | |
sieve[j] = number; | |
} |
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
async moveToInterview(application, interview) { | |
const user = await userApi.getUser(application.userId); | |
const teacherName = user.name.split(' ')[0]; | |
const interviewDateStr = moment(interview.startTime).tz("Asia/Jakarta").format("DD-MMM @ HH:mm z"); | |
const demoClassGroupChat = await skypeApi.createInterviewChannel(`Online class with teacher ${teacherName}`, []); | |
application.demoChatUrl = demoClassGroupChat.joinUrl; | |
deskApi.mailOnTicket(application.ticketNumber, user.email, "Teacher application - invitation to interview", interviewMailTemplate(user, application, interview)); |
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
async function createFreeTrialReimbursements(studentIds, courseId, userId) { | |
return Promise.all(studentIds.map(async (studentId) => { | |
const purchaseHistory = await courseApi.getPurchasesForAStudentInACourse(studentId, courseId); | |
// no purchases | |
if (purchaseHistory.length === 0) | |
return | |
// we already have a paid purchase | |
if (purchaseHistory.filter(p => p.price > 0).length !== 0) | |
return | |
// we dont have a paid purchase |
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
def arithematic_subarray(array): | |
if len(array) < 3: | |
return 0 | |
iteration_count = 1 | |
difference = array[1] - array[0] | |
res = 0 | |
for i in range(2, len(array)): | |
diff = array[i] - array[i-1] | |
if diff == difference: | |
iteration_count += 1 |
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
export const teacherAvailableSchedulesCtrl = { | |
async create(schedule, params) { | |
const teacherId = params.auth.teacherId | |
const existingSchedule = (await teacherAvailabilitySchedulesDao.find({query: {teacherId}}))[0]; | |
if (existingSchedule) { | |
return teacherAvailabilitySchedulesDao.update(existingSchedule._id, { | |
...existingSchedule, | |
schedule: schedule.schedule |
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 readline = require("readline"); | |
let rlSync = require('readline-sync'); | |
function calcScore(actual, guessed) { | |
const result = { correctPos: 0, incorrectPos: 0 }; | |
for (let i = 0; i < actual.length; i++) { | |
if (actual[i] === guessed[i]) { | |
actual.splice(i, 1); | |
guessed.splice(i, 1); | |
result.correctPos += 1; |
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 readline = require("readline"); | |
let rlSync = require('readline-sync'); | |
function calcScore(actual, guessed) { | |
const result = { correctPos: 0, incorrectPos: 0 }; | |
for (let i = 0; i < actual.length; i++) { | |
if (actual[i] === guessed[i]) { | |
actual.splice(i, 1); | |
guessed.splice(i, 1); | |
result.correctPos += 1; |
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
def calcScore(actual, guessed): | |
result = { "correctPos": 0, "incorrectPos": 0} | |
for idx, val in enumerate(guessed): | |
if val in actual: | |
if actual[idx] is val: | |
result['correctPos'] += 1 | |
else: | |
result['incorrectPos'] += 1 | |
print(result) | |
return result |
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 {coursesDao as dao} from './coursesDao'; | |
import {enrichCoursesWithPIIFilteredTeacherProfiles} from "./coursesCtrl"; | |
import {classRequestApi} from "../api/classRequestApi"; | |
import {courseApi} from "../api/courseApi"; | |
import {purchasesDao} from "../purchases/purchasesDao"; | |
import {findEnrolledStudentIdsForNextMeeting} from "../students/enrolmentCheckSvc"; | |
const errors = require('@feathersjs/errors'); | |
export const onlinePublicCoursesCtrl = { |