Skip to content

Instantly share code, notes, and snippets.

@demdxx
demdxx / mysql_cosine_similarity.sql
Created July 18, 2020 19:33
Cosine Similarity implementation in MySQL
-- for calculation of norm vector --
DELIMITER $$
CREATE FUNCTION vector_norm( vector JSON )
RETURNS DOUBLE
READS SQL DATA
DETERMINISTIC
BEGIN
DECLARE array_length INTEGER(11);
DECLARE retval DOUBLE(19,2);
@GhazanfarMir
GhazanfarMir / Instructions.sh
Last active May 14, 2024 03:26
Install PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04
########## Install NGINX ##############
# Install software-properties-common package to give us add-apt-repository package
sudo apt-get install -y software-properties-common
# Install latest nginx version from community maintained ppa
sudo add-apt-repository ppa:nginx/stable
# Update packages after adding ppa
@noporpoise
noporpoise / unifieddiff.py
Last active July 11, 2024 11:13
Apply unified diff patches in pure python2/3
#!/usr/bin/env python
# coding=utf-8
# License: Public domain (CC0)
# Isaac Turner 2016/12/05
from __future__ import print_function
import difflib
import re
@saksmt
saksmt / TableRendererInterface.php
Last active August 29, 2015 14:17
Abstraction on table rendering
<?php
/**
* @example
* $htmlRenderer = new HtmlRenderer();
* $consoleRenderer = new ConsoleRenderer();
* $htmlRenderer->renderToFile($view, 'some.html', [ TableRendererInterface::STREAMED ]);
* echo $consoleRenderer->renderToString($profilingView);
*/
interface TableRendererInterface
@DanielMarklund
DanielMarklund / gist:3415529
Created August 21, 2012 13:39
Laravel - Navigation Active Class
<!-- Example on how to set class="active" on active navigation links -->
<!-- These links will always be visible -->
<li class="{{ URI::is( 'home') ? 'active' : '' }}">
<a href="{{ URL::to( 'home') }}">
Home
</a>
</li>
<li class="{{ URI::is( 'gallery') ? 'active' : '' }}">