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
import React, { useState, useEffect } from 'react'; | |
import axios from 'axios'; | |
const TodoComponent = () => { | |
const [todos, setTodos] = useState([]); | |
const [newTodo, setNewTodo] = useState(''); | |
const [editTodoId, setEditTodoId] = useState(null); | |
const [editedTodoText, setEditedTodoText] = useState(''); | |
const [loading, setLoading] = useState(false); | |
const [error, setError] = useState(''); |
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
import http from "http"; | |
import url from "url"; | |
import seed from "./seed.json" assert { type: "json" }; | |
const items = structuredClone(seed); | |
let nextId = items.length ? items.at(-1).id + 1 : 0; | |
function GET(req, res) { | |
const queryObject = url.parse(req.url, true).query; |
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
// binary search | |
export default function binarySearchIndex(list: number[], target: number): number { | |
let lo = 0; | |
let hi = list.length - 1; | |
while (lo <= hi) { | |
const mid = lo + Math.floor((hi - lo) / 2); | |
if (list[mid] === target) { | |
return mid; |
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 http = require('http'); | |
const server = http.createServer((req, res) => { | |
// Check the value of the "Brand" header | |
const brandHeader = req.headers['brand']; | |
// Define port mappings based on brand | |
const portMapping = { | |
'BrandA': 3001, | |
'BrandB': 3002, |
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
module.exports = { | |
root: true, | |
env: {browser: true, es2020: true}, | |
extends: [ | |
'eslint:recommended', | |
'plugin:@typescript-eslint/recommended', | |
'@bengineer.dev/core' | |
], | |
parser: '@typescript-eslint/parser', | |
rules: { |
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
map $http_brand $brand_port { | |
ACME 3001; | |
LEXCORP 3002; | |
default 0; | |
} | |
server { | |
listen 80; | |
server_name localhost; |
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
function csvParser(raw) { | |
const collector = []; | |
let line = []; | |
let isWithinQuotes = false; | |
let buffer = ''; | |
for (let char of raw) { | |
// if a quote appeared and the previous character wasn't an escape character | |
if (char === '"' && buffer[buffer.length - 1] !== '\\') { | |
isWithinQuotes = !isWithinQuotes; |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
<link rel="stylesheet" href="index.css"> | |
</head> | |
<body> | |
<canvas id="canvas"></canvas> | |
<div class="item"> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
## Top artists -- Short Term (4 weeks) | |
The Black Keys | |
ConcernedApe | |
DAYBREAK | |
Ball Park Music | |
Thomas Newman | |
天府事變 | |
Taylor Swift | |
Lofi Hip-Hop Beats | |
Jaroslav Beck |
NewerOlder