Skip to content

Instantly share code, notes, and snippets.

View trkhanh's full-sized avatar

Tran Khanh trkhanh

View GitHub Profile
@trkhanh
trkhanh / memoization.js
Created June 13, 2022 03:14
memoization.js
const memoize = (f) => {
const cache = {};
return (...args) => {
const argSta = JSON.stringify(args)
cache[argStr] = cache[argStr] || f(...arg);
return cache[argStr];
}
}
const squareNumber = memoize(x => x * x);
@trkhanh
trkhanh / memoize.js
Last active September 22, 2022 08:22
Creates a function that memoizes the result of `func`
/**
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `memoize.Cache`
* constructor with one whose instances implement the
@trkhanh
trkhanh / princess.html
Last active November 8, 2024 03:24
princess.game.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Save the Princess Game</title>
<style>
/* General Styles */
* {
box-sizing: border-box;
@trkhanh
trkhanh / install-python3-jupyter-notebooks.ps1
Created January 27, 2025 07:16 — forked from ergin/install-python3-jupyter-notebooks.ps1
Installation of Scoop, Python 3, Jupyter Notebooks, Pandas, Numpy, Matplotlib, Sklearn on Windows with Powershell
# Make sure PowerShell 5 (or later, include PowerShell Core) and .NET Framework 4.5 (or later) are installed. Then run the following steps.
# Install Scoop
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
# Note: if you get an error you might need to change the execution policy (i.e. enable Powershell) with Set-ExecutionPolicy RemoteSigned -scope CurrentUser
# Install Python 3
scoop install python
# Upgrade pip