Skip to content

Instantly share code, notes, and snippets.

@cvvs
cvvs / random_things.nu
Last active June 16, 2023 21:19
NuShell Goodness
# Grug Parse Prometheus Metrics
# Add other labels of interest (this matches too, eg, my_label1 and label1 would both match)
http get http://host.example.com | lines | where { |line| $line !~ '$'^#' } | parse -r '^(?P<metric>\w+)\{.*label1="(?P<label1>\w+)".*} (?<value>[\de\.\+]+)'
@cvvs
cvvs / binary_jaccard_index.py
Created May 11, 2018 23:52 — forked from saeedizadi/binary_jaccard_index.py
Binary Jaccard Index in Lasagne
def binary_jaccard_index(predictions,targets):
"""Computes the binary (generalized) Jaccard index between predictions and targets.
.. math:: L_i = \\sum_i{\\min(p_i,t_i} / \\sum_i{\\max(p_i,t_i}
Parameters
----------
predictions : Theano tensor
Predictions in [0, 1], such as a sigmoidal output of a neural network,
giving the probability of the positive class
targets : Theano tensor
Targets in {0, 1}, such as ground truth labels.
@cvvs
cvvs / setup.py
Created August 10, 2016 19:39
Working setup.py with a requires numpy (without numpy include_dirs)
#from distutils.core import setup, Extension
#import numpy
from setuptools import setup, Extension
cpu_hamming = Extension('cpu_hamming',
define_macros=[('MAJOR_VERSION', '0'),
('MINOR_VERSION', '6')],
libraries=['m'],
extra_compile_args=["-pthread", "--std=c++0x", "-msse4.2",
"-funroll-loops", "-O3", "-mfpmath=sse"],
package main
import "fmt"
func main() {
var stringSet map[string]interface{} = make(map[string]interface{})
stringSet["apple"] = nil
stringSet["orange"] = nil