This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Code | |
| $("button").single_double_click(function () { | |
| alert("Try double-clicking me!") | |
| }, function () { | |
| alert("Double click detected, I'm hiding") | |
| $(this).hide() | |
| }) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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; |