Skip to content

Instantly share code, notes, and snippets.

/**
* Update Event Logs convertedTime
*/
function convertToCST(utcTimestamp) {
// Parse the UTC timestamp string into a Date object
const date = new Date(utcTimestamp);
// Check if daylight saving time (DST) is in effect
const isDST = () => {
const january = new Date(date.getFullYear(), 0, 1);
@cesarkohl
cesarkohl / fibonacci.ts
Last active May 18, 2023 13:57
Fibonacci
function fibonacci(len) {
const arr = [];
////
// Moved the conditionals out of the loop
if (len >= 1) {
arr.push(0);
}
if (len >= 2) {
export interface IKeyCollection<T> {
add(key: string, value: T);
containsKey(key: string): boolean;
size(): number;
getItem(key: string): T;
removeItem(key: string): T;
getKeys(): string[];
values(): T[];
}
@cesarkohl
cesarkohl / .env
Created August 23, 2021 16:07
JWT Node
SECRET=mySecret
@cesarkohl
cesarkohl / sketchToBitmap.sh
Last active January 15, 2021 11:57
Sketch to Bitmap
################################################################################
################################################################################
# Main program #
################################################################################
################################################################################
Main()
{
echo Duplicating ${1}...
cp ${1} sketch.zip
Now as far for implementation of your REST, these are the typical implementation that I have encountered:
GET /logout
Execute logout in the backend and return JSON for denoting the success/failure of the operation
POST /login
Submit credentials to the backend. Return success/failure. If successful, normally it will also return the session token as well as the profile information.
POST /register
Submit registration to the backend. Return success/failure. If successful, normally treated the same as successful login or you could choose to make registration as a distinct service
<!DOCTYPE html>
<html>
<head>
<script src="main.js"></script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src="script-1.js"></script>
<script src="script-2.js"></script>
<script src="script-3.js"></script>
</head>
<body>
</body>
</html>
let value = 0;
if (true) {
 // new scope, TDZ of 'value' begins
// When trying to access the variable, we take ReferenceError,
// because right now it's a variable
 // not initialized
 console.log (value); // ReferenceError
let value; // TDZ ends and 'value' is set to 'undefined'
 console.log (value); // undefined
value = 1;