Skip to content

Instantly share code, notes, and snippets.

@yogin16
yogin16 / curve.py
Last active March 10, 2019 14:10
curve-fitting example
"""
The code is implementation of techniques in this lecture: https://www.essie.ufl.edu/~kgurl/Classes/Lect3421/Fall_01/NM5_curve_f01.pdf
"""
import matplotlib.pyplot as plt
import numpy as np
def curve(X, Y, order):
sigma_x=[]
for i in range(2*order + 1):
@yogin16
yogin16 / TfidfExample.java
Created April 10, 2018 17:26
TfidfVectorizer.java
import org.deeplearning4j.bagofwords.vectorizer.TfidfVectorizer;
import org.deeplearning4j.models.word2vec.VocabWord;
import org.deeplearning4j.models.word2vec.wordstore.VocabCache;
import org.deeplearning4j.models.word2vec.wordstore.inmemory.AbstractCache;
import org.deeplearning4j.text.documentiterator.LabelAwareIterator;
import org.deeplearning4j.text.documentiterator.LabelledDocument;
import org.deeplearning4j.text.documentiterator.LabelsSource;
import org.deeplearning4j.text.tokenization.tokenizerfactory.DefaultTokenizerFactory;
import org.nd4j.linalg.api.ndarray.INDArray;
@yogin16
yogin16 / cleanSpringRedisCache.lua
Last active July 4, 2018 09:50
Lua script for cleaning Spring's Redis cache (@Cacheable)
-- $ ./redis-cli --eval cleanSpringRedisCache.lua <CACHE_NAME>
local logtable = {}
local function logit(msg)
logtable[#logtable+1] = msg
end
local cacheName=KEYS[1]..'~keys'
logit('Cache: '..cacheName)
local cacheValues=redis.call("zrevrange", cacheName, 0, 100)
@yogin16
yogin16 / gist:7ea39f90bbb6f61ef2b086b114c7c59c
Created October 26, 2017 17:38
Vespa Aggregation - Timeout with limit and unranked.
curl 'http://localhost:8080/search/?yql=select%20*%20from%20sources%20*%20where%20(sddocname%20contains%20(%5B%7B%22implicitTransforms%22%3A%20false%7D%5D%22tweet%22))%20limit%200%20%7C%20all(group(n_tA_c)%20max(1)%20each(output(count()%20as(count))))%3B&ranking=unranked' | python -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 472 100 472 0 0 23 0 0:00:20 0:00:20 --:--:-- 118
{
"root": {
"children": [
{
"children": [
{
@yogin16
yogin16 / gist:7fd57ab33b65fb50e24b3e26529d92ed
Created October 26, 2017 17:05
Vespa aggregation - timeout
curl 'http://localhost:8080/search/?yql=select%20*%20from%20sources%20*%20where%20(sddocname%20contains%20(%5B%7B%22implicitTransforms%22%3A%20false%7D%5D%22tweet%22))%20%7C%20all(group(n_tA_c)%20max(10)%20each(output(count()%20as(count))))%3B' | python -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1234 0 1234 0 0 61 0 --:--:-- 0:00:20 --:--:-- 308
{
"root": {
"children": [
{
"children": [
{