Skip to content

Instantly share code, notes, and snippets.

@mukoladeath
mukoladeath / doubleclick_emulate.js
Created March 28, 2019 13:18
bind one and double click, to single onclick event
//global var
var lastClick = 0;
$("#target").click(function() {
var d = new Date();
var t = d.getTime();
if(t - lastClick < 400) {
//two clicks
}else{
//one click
}
@mukoladeath
mukoladeath / README
Created March 26, 2019 10:00 — forked from ncr/README
Code
$("button").single_double_click(function () {
alert("Try double-clicking me!")
}, function () {
alert("Double click detected, I'm hiding")
$(this).hide()
})
@mukoladeath
mukoladeath / pano-converter3.py
Created March 4, 2019 22:02 — forked from muminoff/pano-converter3.py
Equirectangular panorama to cube map (Python 3)
import sys
from PIL import Image
from math import pi,sin,cos,tan,atan2,hypot,floor
from numpy import clip
# get x,y,z coords from out image pixels coords
# i,j are pixel coords
# face is face number
# edge is edge length
def outImgToXYZ(i,j,face,edge):
@mukoladeath
mukoladeath / uniq_id.js
Created February 24, 2019 17:44
Uniqid function, based on pure javascript Time and Random
//uniqId('_')
//"_jsj7byjvm1f6df87o"
//uniqId('.')
//".jsj7c2bbo0nydbmwi"
//uniqId('prefix_')
//"prefix_jsj7cdqe37ecl3eig"
function uniqId(separator){
var separator = separator || '';
return separator+(new Date().getTime()).toString(36)+Math.random().toString(36).substr(2, 9);
@mukoladeath
mukoladeath / detectmob
Created February 3, 2019 20:43
detectmob
//easy but useful
function detectmob() {
if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) {
return true;
} else {
return false;
}
}
@mukoladeath
mukoladeath / getImgSizeInfo.js
Last active February 3, 2019 13:45
get rendered image size, get object-fit image dimensions
function getRenderedSize(contains, cWidth, cHeight, width, height, pos){
var oRatio = width / height,
cRatio = cWidth / cHeight;
return function() {
if (contains ? (oRatio > cRatio) : (oRatio < cRatio)) {
this.width = cWidth;
this.height = cWidth / oRatio;
} else {
this.width = cHeight * oRatio;
this.height = cHeight;
@mukoladeath
mukoladeath / browser_detect.js
Created January 24, 2019 23:23 — forked from 2107/browser_detect.js
JavaScript: Detect Browser
// browser detect
var BrowserDetect = {
init: function() {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function(data) {
for (var i = 0; i < data.length; i++) {
var dataString = data[i].string;