Skip to content

Instantly share code, notes, and snippets.

View horiacristescu's full-sized avatar

Horia Cristescu horiacristescu

  • Bucharest
View GitHub Profile
@horiacristescu
horiacristescu / rank.py
Last active December 9, 2019 18:02
Ranking by dot product
def inner_product_rank(self, vecs, threshold=0.5):
sims_mat = np.dot(vecs, vecs.transpose())
sims_mat = sims_mat - threshold
sims_mat[sims_mat<0] = 0
ranks = np.sum(sims_mat, axis=0)
return ranks
@horiacristescu
horiacristescu / bookmarklet.js
Last active April 3, 2018 04:48
Text to Speech Bookmarklet
Make a bookmarklet with this code:
javascript:!function(e){function t(u){if(n[u])return n[u].exports;var r=n[u]={exports:{},id:u,loaded:!1};return e[u].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){function u(){}function r(e){console.log("pageX",e.pageX,"pageY",e.pageY),T("#speaker").css({left:e.pageX-T("#speaker").width()/2+15,top:e.pageY-T("#speaker").height()/2+15,display:"block",width:"100px",height:"100px","margin-left":"-30px","margin-top":"-30px",opacity:"1"}),T("#speaker").each(function(e,t){T(t).animate({opacity:0,left:"+="+T(t).width()/4,top:"+="+T(t).height()/4,height:0,width:0},500,function(){T(t).hide()})})}function i(e,t,n){if("SCRIPT"!=e.tagName&&"math"!=e.tagName&&"CODE"!=e.tagName&&"BUTTON"!=e.tagName&&"STYLE"!=e.tagName&&"ASIDE"!=e.tagName&&"PRE"!=e.tagName){var u=T(e).css("float"),r="left"==u||"right"==u;if(!(T(e).width()<500&&r)){if(e.classList)for(var o=0;o<e.classList.length;o++){if("word"==e.classList[o]||"MathJax"==e.clas