Skip to content

Instantly share code, notes, and snippets.

View mrm8488's full-sized avatar
🏠
Working from home

Manuel Romero mrm8488

🏠
Working from home
View GitHub Profile
const getUserInfo = () => new Promise((resolve, reject) => {
process.nextTick(() => resolve({
id: 1,
name: 'Manuel',
surname: 'Romero'
}));
});
const getUserInfo = () => new Promise((resolve, reject) => {
process.nextTick(() => resolve({
id: 1,
name: 'Manuel',
surname: 'Romero'
}));
});
@mrm8488
mrm8488 / from_callbacks_to_util.promisify().js
Last active March 21, 2019 19:25
Here we can see how Node.js 8 allow us to promisify I/O functions that return callbacks (without 3pp modules such as Q or Bluebird)
/* 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);
@mrm8488
mrm8488 / README.md
Created October 24, 2019 01:09 — forked from notwaldorf/README.md
ServiceWorker code to cache Tensorflow model shards.

ServiceWorker code to cache TensorFlow model shards.

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.

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.
# 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)
// 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);
<html>
<head>
<style>
body {
margin: 0;
height: 100vh;
width: 100vw;
}
</style>
@mrm8488
mrm8488 / an-inquiry-into-matplotlib-figures.ipynb
Created December 23, 2019 20:55 — forked from akashpalrecha/an-inquiry-into-matplotlib-figures.ipynb
This notebook dives deep into Matplotlib's Figures, Axes, subplots and the very amazing GridSpec!
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mrm8488
mrm8488 / vector_matrix.js
Created January 3, 2020 21:49
Create a vector and a matrix in JS
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);