Skip to content

Instantly share code, notes, and snippets.

View loretoparisi's full-sized avatar
🐍
NightShift

Loreto Parisi loretoparisi

🐍
NightShift
View GitHub Profile
@alexellis
alexellis / README.md
Last active May 19, 2022 02:17
OpenFaaS Redis example

Redis & OpenFaaS micro-tutorial

After you've completed this micro-tutorial you'll be making requests to your Redis cache from serverless functions with OpenFaaS. From there it's up to you to build something awesome.

Pre-reqs:

Deploy OpenFaaS and the faas-cli.

This guide is for OpenFaaS on Kubernetes, but if you're using Swarm that's OK - you'll just have to adapt some of the commands for setting up Redis. The OpenFaaS code will be the same.

#!/bin/bash
SOURCE=$1
TARGET=eng
IN=$2
OUT=$3
while read -r col1 rest; do
printf '%s\t%s\n' "$col1" "$(indictrans -s $SOURCE -t $TARGET --ml --build-lookup <<<"$rest")"
done < $IN > $OUT
@manrajgrover
manrajgrover / .env.sample
Last active January 29, 2024 12:56
Quick Docker Environment for TensorFlowJS Node
root=/path/to/root
project=/path/to/project
@loretoparisi
loretoparisi / shuffle_fisher_yates.js
Last active June 30, 2018 11:54
Shuffle Array in JavaScript
/**
* Shuffle array
* Fisher-Yates (aka Knuth) Shuffle
*/
let shuffle = (array) => {
var currentIndex = array.length, temporaryValue, randomIndex;
while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
temporaryValue = array[currentIndex];
@loretoparisi
loretoparisi / random_arbitrary.js
Last active June 30, 2018 11:44
Get a random number in JavaScript
/**
* Returns a random number between min (inclusive) and max (exclusive)
*/
let getRandomArbitrary => (min, max, fixed) {
fixed=fixed=10;
return (Math.random() * (max - min) + min).toFixed(fixed);
}
@loretoparisi
loretoparisi / blob_read_write.js
Last active April 24, 2018 14:20
HTML5 Blob Read / Write File API
/**
* Save or open HTML 5 Blob Object-URL
* @see https://stackoverflow.com/questions/22724070/prompt-file-download-with-xmlhttprequest
* @param blob Blob
* @param fileBName String
*/
function saveOrOpenBlob(blob, fileName) {
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(window.TEMPORARY, 1024 * 1024, function (fs) {
fs.root.getFile(fileName, { create: true }, function (fileEntry) {
#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
inp = Input(shape=(maxlen,), name="text_input") # featureized text comes in here
x = Embedding(embedding_matrix.shape[0], embed_size, weights=[embedding_matrix], trainable=True)(inp)
x = Dense(some_num_here, activation="relu")(x)
extra_data = Input(shape=(1,), name="extra_data") # your continous features comes in here
combined = concatenate([x, extra_data])
# maybe some ReLu + Dropout here
@loretoparisi
loretoparisi / jsmin.c
Created January 11, 2018 22:03
JavaScript Minifier in C By Douglas Crockford (www.crockford.com)
/* jsmin.c
2008-08-03
Copyright (c) 2002 Douglas Crockford (www.crockford.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
@loretoparisi
loretoparisi / git_remote_init.sh
Created January 10, 2018 23:12
Git Init Repository from Remote Origin
git init
git add .
git commit -m "First commit"
git remote add origin $GIT_REMOTE_ORIGIN
git remote -v
git pull --allow-unrelated-histories origin master
git push -u origin master