Skip to content

Instantly share code, notes, and snippets.

View stoneboyindc's full-sized avatar

Nick Chang stoneboyindc

View GitHub Profile
@stoneboyindc
stoneboyindc / PersonRepository.java
Created January 19, 2024 21:14
This is a refactor of PersonRepository to load the csv and also add "getPersons()" method
import com.jsoniter.JsonIterator;
import com.jsoniter.any.Any;
import com.oc.projectone.dataminer.model.Person;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
@stoneboyindc
stoneboyindc / phase1.py
Created January 19, 2024 20:58
Use function.
from bs4 import BeautifulSoup
import requests
import pandas as pd
def process_single_book(website):
# Get Request and Status Code
response = requests.get(website, verify=False)
# print(response.status_code)
function botGreeting() {
return "Hello, I'm the Getaway Bot! I want to help you find your dream destination. You can ask me about our current offers, payment, or contact info. Or type 'help'.";
}
function botResponse(message) {
return (
"I'm not sure I understood your message: '" +
message +
"'. Type 'help' to see more options."
);
@stoneboyindc
stoneboyindc / chatbot
Created March 3, 2021 22:26
chatbot.js
// v1
// write a function that says hello from the bot, to be called when the chat starts
function botGreeting() {
return "Hello, I'm the Getaway Bot! I want to help you find your dream destination. You can ask me about our current offers, payment, or contact info. Or type 'help'.";
}
// v2
// When the bot doesn't understand, we still want the bot to give a response to the user. Write a function `botResponse` that explains that the bot didn't understand. It should say "I'm not sure I understood your message: '[message]'. Type 'help' to see more options."
function botResponse(message) {
return (
const faker = require('faker');
function plantGenerator() {
let randomName = faker.name.findName();
let randomColor = faker.color();
return {
name: randomName,
color: randomColor
};
}
@stoneboyindc
stoneboyindc / s.js
Last active December 2, 2022 20:09
It should return an array of all the transactions from the book's `borrows` key. However, each transaction should include the related account information and the `returned` key.
function getBorrowersForBook(book, accounts) {
let result = [];
let borrowArray = book.borrows;
borrowArray.forEach(borrow=>{
let account = accounts.find(acc => acc.id === borrow.id);
let obj = account;
obj['returned'] = borrow.returned;
result.push(obj);
})
console.log(result);
function bulkDelete(ids) {
const promises = ids.map((id) => {
const url = `${BASE_URL}/constellations/${id}`;
return axios.delete(url).then((data)=>{
console.log(data);
return {id};
})
});
return Promise.all(promises);
}
const { welcome, goodbye, tell } = require("../utils/fortune-teller");
function getFortune(question) {
tell(question).then(msg => {
console.log(`Your question was: ${question}`);
console.log(`Your fortune is: ${msg}`)})
.catch(err => console.log('There was an error: A question is required...'));
}
function fullSession(question) {
function allCandyOrders(inventory) {
let result = {};
for (let i=0; i<inventory.length; i++) {
if (inventory[i].inStock < inventory[i].weeklyAverage) {
result[inventory[i].candy]= inventory[i].weeklyAverage * 2;
} else {
result[inventory[i].candy] = 0;
}
}
return result;
@stoneboyindc
stoneboyindc / solution.js
Last active August 6, 2021 15:32
getBooksPossessedByAccount()
function getBooksPossessedByAccount(account, books, authors) {
//Initialze a return array
let booksPossessed=[];
//check for the account id in the borrows arrays
books.forEach(book => {
let borrowArray = book.borrows;
if (borrowArray.find(borrow => borrow.id === account.id && borrow.returned === false)) {
booksPossessed.push(book);
}
})