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)
// should return all of the books taken out by an account with the author embedded
function getBooksPossessedByAccount(account, books, authors) {
let books_taken = [];
books.forEach(book=>{
if (book.borrows.find(item=>item.id === account.id && !item.returned)) {
books_taken.push(book);
}
})
console.log(books_taken);
books_taken.forEach(book=>{
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);
}
function addProductToCart({ name, priceInCents }, cart = {}) {
const selected = cart[name];
if (selected) {
selected.quantity++;
} else {
cart[name] = { priceInCents, quantity: 1 };
}
return cart;
}
function printNames (names) {
names.forEach(name => console.log(name));
}
function logTreeType (trees) {
trees.forEach(type => console.log(type.type));
}
function totalPoints(points) {
// your solution here
function Display(props) {
const list = hobbies.map((hobby) => <li>{hobby}</li>);
return (<div>
<h3>Hobbies</h3>
<ul>{list}</ul>
</div>)
const rows = dailyActivities.map(({time, description}, index) =>(
<tr key={index}>
<td>{time}</td>
<td>{description}</td>
import React from "react";
function App() {
const name = "Kitty Kat";
const birthday = "January 1";
const imageSrc =
"https://images.pexels.com/photos/45201/kitty-cat-kitten-pet-45201.jpeg";
const hobbies = ["watching birds", "hiding in a box", "napping"];
const dailyActivities = [
{ time: "8:00 am", description: "wake up" },
function showHelpOptions(message){
let str = ""
for(let i=0; message.length>i; i++){
if (i!== message.length -1) {
str += message[i] + ", ";
} else {
str += message[i] + ".";
}
}
return "Enter a keyword for help with a topic: " + str;
@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 (