Instantly share code, notes, and snippets.

🎯
Focusing

Loreto Parisi loretoparisi

View GitHub Profile
View react-error-logging.js
// This module is forked in different environments.
// By default, return `true` to log errors to the console.
// Forks can return `false` if this isn't desirable.
function showErrorDialog(capturedError) {
return true;
}
function logCapturedError(capturedError) {
var logError = showErrorDialog(capturedError);
View replace_tokens_word_boundary_unicode_ascii.js
/**
* Replace tokens in text
* It support both Unicode and ASCII Regex for word boundaries
* @param {*} isUnicode true to use Unicode Regex
* @param {*} text input text
* @param {*} tokens Tokens indexes
* @param {*} words Words
* @param {*} expr Replacement
*/
var replaceTokens = function (isUnicode, text, tokens, words, expr) {
View pca.json
{
"name": "PCA",
"center": true,
"scale": true,
"means": [
787985,
532998,
1319441,
541986,
1852689,
View hashes.json
[
[
787985,
532998,
1319441,
541986,
1852689,
1181986,
1706246,
2492689,
View prepare_listener.py
from keras.models import Model
from keras.layers import Input, LSTM, RepeatVector
def prepare_listener(timesteps,
input_dim,
latent_dim,
optimizer_type,
loss_type):
"""Prepares Seq2Seq autoencoder model
Args:
View GammatoneFilterbank.py
from gammatone import gtgram
import numpy as np
class GammatoneFilterbank:
# Initialize Gammatone filterbank
def __init__(self,
sample_rate,
window_time,
hop_time,
num_filters,
View CircularBuffer.py
import numpy as np
class CircularBuffer():
# Initializes NumPy array and head/tail pointers
def __init__(self, capacity, dtype=float):
self._buffer = np.zeros(capacity, dtype)
self._head_index = 0
self._tail_index = 0
self._capacity = capacity
# Makes sure that head and tail pointers cycle back around
def fix_indices(self):
View content_range.log
*** REQUEST 1 ***
GET /streams/12380189?start=5&end=10 HTTP/1.1
Host: my_host
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7,es;q=0.6,de;q=0.5,ru;q=0.4
View word_count.js
words=text.split(/\s+/g)
count=words.reduce(function(m,v) {m[v] = m[v] ? m[v] + 1 : 1; return m;}, {})
sorted=Object.keys(chart).sort((a,b) => chart[b]-chart[a]).map(token => { var x=new Object(); x[token]=chart[token]; return x;} )
View readStream.js
{
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 65536,
buffer: BufferList { length: 0 },
length: 0,
pipes: null,
pipesCount: 0,
flowing: null,