Skip to content

Instantly share code, notes, and snippets.

View trkhanh's full-sized avatar

Tran Khanh trkhanh

View GitHub Profile
@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
@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 / 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 / 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 / index.js
Created June 4, 2022 04:49
db-index
var async = require('async');
var ShareDBError = require('../error');
function DB(options) {
// pollDebounce is the minimum time in ms between query polls
this.pollDebounce = options && options.pollDebounce;
}
module.exports = DB;
// When false, Backend will handle projections instead of DB
@trkhanh
trkhanh / blob.jsx
Last active May 30, 2022 12:53
blob-example
import '@mohayonao/web-audio-api-shim'
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import Player from './components/player'
import FilePicker from './components/file'
import { isAudio, readBlobURL, download, rename, sliceAudioBuffer } from './utils'
import { encode } from './worker-client'
import WebAudio from './webaudio'
import { Box, Button, ButtonGroup, FormControl, InputLabel, Select, MenuItem } from "@mui/material";
import PlayArrow from '@mui/icons-material/PlayArrow'
Xoá rồi nhé
@trkhanh
trkhanh / install-go-to-with-bash-script.md
Created October 17, 2021 05:01 — forked from d2s/install-go-to-with-bash-script.md
Installing Go with command line

NOTE: This is heavily outdated Gist snippet from 2017.


Install Go language with a Bash script

Another alternative to installing Go is to use a simple Bash script. It will download and install Go language under of your own user account.

Note that a system-wide installation might be better for some things

@trkhanh
trkhanh / InfixtoPostfix.js
Created August 31, 2021 10:16
polish-algo
// Created an empty array
var stackarr = [];
// Variable topp initialized with -1
var topp = -1;
// Push function for pushing
// elements inside stack
function push(e) {
topp++;
@trkhanh
trkhanh / hashtable.js
Created July 5, 2021 07:22
Hash Table
class HashTable {
constructor() {
this.table = new Array(127);
this.size = 0;
}
_hash(key) {
let hash = 0;
for (let i = 0; i < key.length; i++) {
hash += key.charCodeAt(i);