One of the problems I have when testing giant TensorFlow models in TensorFlow.js is that they're huge (like 500 MB) and they take forever to download, every time I refresh the page. This is how I setup my ServiceWorker code so that at least in testing I only have to download the model once, and then it's saved in the cache for the next time.
This file contains 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 getUserInfo = () => new Promise((resolve, reject) => { | |
process.nextTick(() => resolve({ | |
id: 1, | |
name: 'Manuel', | |
surname: 'Romero' | |
})); | |
}); |
This file contains 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 getUserInfo = () => new Promise((resolve, reject) => { | |
process.nextTick(() => resolve({ | |
id: 1, | |
name: 'Manuel', | |
surname: 'Romero' | |
})); | |
}); |
This file contains 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
/* AUTHOR: mrm8488@gmail.com */ | |
/* Node.js v8 */ | |
const fs = require('fs'); | |
/* BEFORE util.promisify() */ | |
fs.writeFile('/tmp/test.js',"console.log('Hello world');", error => { | |
if(error) return console.log(error); |
This file contains 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
tail -F firewall.log |while | |
read -r line;do printf | |
"\033[38;5;%dm%s\033[0m\n" $ | |
((SRANDOM%255)) "Sline";done # | |
Random color per log line. |
This file contains 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
# Detect hardware | |
try: | |
tpu = tf.distribute.cluster_resolver.TPUClusterResolver() # TPU detection | |
except ValueError: | |
tpu = None | |
gpus = tf.config.experimental.list_logical_devices("GPU") | |
# Select appropriate distribution strategy | |
if tpu: | |
tf.config.experimental_connect_to_cluster(tpu) |
This file contains 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
// Node.js readline & async iteration: | |
const fs = require('fs"); | |
const {createlnterface: ci} = | |
require('readline’); | |
async function logLines(ls) { | |
for await (const l of ls) { | |
console.log('>"' + l); |
This file contains 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
<html> | |
<head> | |
<style> | |
body { | |
margin: 0; | |
height: 100vh; | |
width: 100vw; | |
} | |
</style> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 array = (size,value = 0) => Array(size).fill(value); | |
let a = array(n); | |
const matrix = (rows,cols,value = 0) => Array(rows).fill(Array(cols).fill(value)); | |
let m = matrix(r,c); |