Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍

Loreto Parisi loretoparisi

🐍
View GitHub Profile
@loretoparisi
loretoparisi / tokenizer_unicode.js
Last active Oct 15, 2020
Unicode aware Regex Tokenizer in JavaScript with token char offset begin and end
View tokenizer_unicode.js
function aggressive_tokenizer(text) {
// most punctuation
text = text.replace(/[^\w\.\-\/\+\<\>,&]/g, " $& ");
// commas if followed by space
text = text.replace(/(,\s)/g, " $1");
// single quotes if followed by a space
text = text.replace(/('\s)/g, " $1");
// single quotes if last char
text = text.replace(/('$)/, " $1");
text = text.replace(/(\s+[`'"‘])(\w+)\b(?!\2)/g, " $2");
@loretoparisi
loretoparisi / test.js
Created Oct 2, 2020 — forked from vladmandic/test.js
TFJS Test for EfficientDet Models
View test.js
const fs = require('fs');
const path = require('path');
const log = require('@vladmandic/pilogger');
const tf = require('@tensorflow/tfjs');
const tfnode = require('@tensorflow/tfjs-node');
function getTensorFromImage(path) {
if (!fs.existsSync(path)) return null;
const data = fs.readFileSync(path);
const tfimage = tfnode.node.decodeImage(data);
View count_files.sh
#!/bin/bash
count() {
awk 'BEGIN {
unit["Bytes"] = 1;
unit["kB"] = 10**3;
unit["MB"] = 10**6;
unit["GB"] = 10**9;
@loretoparisi
loretoparisi / numpy_json_encoder.py
Created Jun 18, 2020
Python Numpy JSON Encoder
View numpy_json_encoder.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# @author loretoparisi at gmail dot com
# Copyright (c) 2020 Loreto Parisi
#
import numpy as np
import json
@loretoparisi
loretoparisi / dataset_stats.py
Created Jun 18, 2020
Dataset Statistics with Python Pandas
View dataset_stats.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# @author loretoparisi at gmail dot com
# Copyright (c) 2020 Loreto Parisi
#
### built-in
import argparse
import json
@loretoparisi
loretoparisi / screams.txt
Created May 12, 2020
Screams Java Regex
View screams.txt
(.{2,}?)([\s|-]*\1.?[\s|-]*){2,}
((.)*-(.)*){2,}
.*(\D)\1{2,}.+
.+(\D)\1{2,}.*
OH
(G)?(E)?(Y|E|A|H|-){4,}
B*(R){2,}
B(R)+(A)+(P)+
B+(O){2,}(M)+(B)+
B(O)+MB(A|O)+CL(A)+(T)+
@loretoparisi
loretoparisi / github_quick_setup.md
Last active May 26, 2020
Github Quick setup — if you’ve done this kind of thing before
View github_quick_setup.md

Get started by creating a new file or uploading an existing file. We recommend every repository include a README, LICENSE, and .gitignore.

…or create a new repository on the command line

echo "# myrepo" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/loretoparisi/myrepo.git
git push -u origin master
@loretoparisi
loretoparisi / report_2020-05-04T070000.txt
Created Apr 22, 2020
Contact Tracing Example report
View report_2020-05-04T070000.txt
Simulation Start Time: 2020-05-04T07:00:00
Family Count: 3
Friend Count: 10
Coworker Count: 50
Other Count: 10
--------------------
Handset ID: 4da604f3acf7448d9d8476774342a645
Relation to subject: family
@loretoparisi
loretoparisi / nodes.js
Last active Apr 10, 2020
nodes example for D3.js circle packing (flare graph)
View nodes.js
NODES= window.LibName || {};
NODES = function () {
data = function() {
return {"children":[{"name":"#0","children":[{"name":"back","size":0.086},{"name":"time","size":0.036},{"name":"dance","size":0.036},{"name":"make","size":0.034},{"name":"summer","size":0.029},{"name":"stay","size":0.029},{"name":"white","size":0.022},{"name":"lying","size":0.022},{"name":"whoa","size":0.021}]},{"name":"#1","children":[{"name":"heart","size":0.086},{"name":"broke","size":0.072},{"name":"story","size":0.061},{"name":"life","size":0.05},{"name":"give","size":0.048},{"name":"start","size":0.025},{"name":"time","size":0.022}]},{"name":"#2","children":[{"name":"make","size":0.087},{"name":"beautiful","size":0.071},{"name":"world","size":0.068},{"name":"baby","size":0.033},{"name":"hair","size":0.03},{"name":"understand","size":0.029},{"name":"light","size":0.025},{"name":"hard","size":0.025},{"name":"ground","size":0.024},{"name":"smile","size":0.023},{"name":"heads","size":0.022},{"name":"hear","size":0.021},{"name":"fli
@loretoparisi
loretoparisi / ec2instances.md
Created Apr 10, 2020 — forked from julien-c/ec2instances.md
simple markdown table of AWS instance types with vCPU/RAM/price (us-east-1)
View ec2instances.md
API Name Memory vCPUs Physical Processor Network Performance Linux On Demand cost Linux Reserved cost
a1.2xlarge 16.0 GiB 8 vCPUs AWS Graviton Processor Up to 10 Gigabit $148.92 monthly $93.80 monthly
a1.4xlarge 32.0 GiB 16 vCPUs AWS Graviton Processor Up to 10 Gigabit $297.84 monthly $187.61 monthly
a1.large 4.0 GiB 2 vCPUs AWS Graviton Processor Up to 10 Gigabit $37.23 monthly $23.43 monthly
a1.medium 2.0 GiB 1 vCPUs AWS Graviton Processor Up to 10 Gigabit $18.61 monthly $11.75 monthly
a1.metal 32.0 GiB 16 vCPUs AWS Graviton Processor Up to 10 Gigabit $297.84 monthly $187.61 monthly
a1.xlarge 8.0 GiB 4 vCPUs AWS Graviton Processor Up to 10 Gigabit $74.46 monthly $46.93 monthly
c1.medium 1.7 GiB 2 vCPUs Intel Xeon Family Moderate $94.90 monthly $66.43 monthly