Skip to content

Instantly share code, notes, and snippets.

@exebetche
exebetche / adjacent_fetch.sql
Created January 1, 2023 16:20
Mysql procedure to get depth first ordered data from adjacent hierarchical tree
BEGIN
DECLARE id INT DEFAULT NULL;
DECLARE pid INT DEFAULT NULL;
DECLARE idx INT DEFAULT NULL;
CREATE TEMPORARY TABLE `temp_table` (
`ord` int NOT NULL AUTO_INCREMENT,
`id` int NOT NULL,
`pid` int,
`idx` int NOT NULL,
DELIMITER ;;
DROP FUNCTION IF EXISTS `slugify`;;
CREATE FUNCTION `slugify`(`original` varchar(512) CHARACTER SET 'utf8mb4') RETURNS varchar(512) CHARSET ascii
BEGIN
DECLARE translit VARCHAR(512) DEFAULT '';
DECLARE len INT(3) DEFAULT 0;
DECLARE pos INT(3) DEFAULT 1;
DECLARE letter CHAR(6);
{
"name": "myLib",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build --target lib --name ${npm_package_name} ./src/main.js"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
@exebetche
exebetche / detectAnimationEnd.js
Created March 7, 2018 01:20 — forked from foolyoghurt/detectAnimationEnd.js
polyfill for detecting AnimationEnd and TransitionEnd event - from ReactTransitionEvents.js
/**
* EVENT_NAME_MAP is used to determine which event fired when a
* transition/animation ends, based on the style property used to
* define that event.
*/
var EVENT_NAME_MAP = {
transitionend: {
'transition': 'transitionend',
'WebkitTransition': 'webkitTransitionEnd',
'MozTransition': 'mozTransitionEnd',
@exebetche
exebetche / gpoint.php
Created February 26, 2016 21:30 — forked from cypres/gpoint.php
PHP class to convert Latitude & Longitude coordinates into UTM & Lambert Conic Conformal Northing/Easting coordinates.
<?php
/**
* PHP class to convert Latitude & Longitude coordinates into UTM & Lambert Conic Conformal Northing/Easting coordinates.
*
* This class encapsulates the methods for representing a geographic point on the earth in three different coordinate systema. Lat/Long, UTM and Lambert Conic Conformal.
*
* Code for datum and UTM conversion was converted from C++ code written by Chuck Gantz (chuck.gantz@globalstar.com) from http://www.gpsy.com/gpsinfo/geotoutm/
* This code was converted into PHP by Brenor Brophy (brenor@sbcglobal.net) and later refactored for PHP 5.3 by Hans Duedal (hd@onlinecity.dk).
*
function parse_object(obj){
var stack =[[Object.keys(obj), obj]],
t = stack[0],
o,
k = t[0].shift();
while(true){
while(k){
/**** save an array of integer to an hexa string and back ***///
function num2b(num, len){
var arr = [],
top = 32-len,
mask=(2<<(len-1))-1,//len:1 is binary
v = num>>>top,
lead=false;
if(v!==0){
var Complex = function(real, imag) {
if (!(this instanceof Complex)) {
return new Complex (real, imag);
}
if (typeof real === "string" && imag == null) {
return Complex.parse (real);
}
this.real = Number(real) || 0;
@exebetche
exebetche / levenshtein.lua
Created May 19, 2014 21:00
Lua implementation of levenshtein distance
function levenshtein(a, b)
if a:len() == 0 then return b:len() end
if b:len() == 0 then return a:len() end
local matrix = {}
local a_len = a:len()+1
local b_len = b:len()+1
-- increment along the first column of each row
for i = 1, b_len do
@exebetche
exebetche / html_parser.lua
Created July 31, 2013 22:00
LUA HTML parser
-- LUA HTML parser
local empty_tags = {
br = true,
hr = true,
img = true,
embed = true,
param = true,
area = true,