Skip to content

Instantly share code, notes, and snippets.

@SubZane
SubZane / input:number
Created April 23, 2014 11:45
Allow only numbers on input:number
$("input[type=number]").keydown(function(event) {
// Allow: backspace, delete, tab, escape, enter and .
if ( $.inArray(event.keyCode,[46,8,9,27,13,190]) !== -1 ||
// Allow: Ctrl+A
(event.keyCode == 65 && event.ctrlKey === true) ||
// Allow: home, end, left, right
(event.keyCode >= 35 && event.keyCode <= 39)) {
// let it happen, don't do anything
return;
}
@SubZane
SubZane / IE Detection Script
Created April 23, 2014 11:46
IE Detection Script
<script>
if (/\bMSIE 6/.test(navigator.userAgent) && !window.opera) {
document.documentElement.className+=' ie6';
} else if (navigator.appVersion.indexOf("MSIE 7.") != -1) {
document.documentElement.className+=' ie7';
} else if (navigator.appVersion.indexOf("MSIE 8.") != -1) {
document.documentElement.className+=' ie8';
} else if (navigator.appVersion.indexOf("MSIE 9.") != -1) {
document.documentElement.className+=' ie9';
} else if (/*@cc_on!@*/false && document.documentMode === 10) {
/* Based on
* - EGM Mathematical Finance class by Enrique Garcia M. <egarcia@egm.co>
* - A Guide to the PMT, FV, IPMT and PPMT Functions by Kevin (aka MWVisa1)
*/
var ExcelFormulas = {
PVIF: function(rate, nper) {
return Math.pow(1 + rate, nper);
},
@SubZane
SubZane / gist:3a53bda42974ec23368f
Created June 2, 2014 11:58
Remove folders from git cache when adding them to .gitignore
git rm --cached -r src/dependencies/
@SubZane
SubZane / guid.js
Last active August 17, 2016 11:31
create a guid using javascript
function guid() {
var strguid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
return strguid;
}
sudo su
mkdir /mnt/timecapsule
echo "//timeCapsuleIp/Data /mnt/toshiba cifs user= timecapsuleUsername,pass= timecapsuleUserPassword,rw,uid=1000,iocharset=utf8,sec=ntlm 0 0" >> /etc/fstab
$ setxkbmap -option apple:badmap
# Place that command into ~/.bashrc file to have it run automatically when you log in.
@SubZane
SubZane / Detect Windows Tablet or Laptop
Created October 13, 2015 13:42
Detect Windows Tablet or Laptop
window.PointerEvent ? "pointer" : "ontouchstart" in window ? "touch" : "mouse";
@SubZane
SubZane / gist:9307cefafea4ba746a38
Last active August 17, 2016 11:30
css center absolute
.center_absolute_positioned {
position: absolute;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
}
@SubZane
SubZane / gist:3f5206fb439d080a8680
Last active May 14, 2023 18:02
Regex to remove empty html tags
<(\w+)\b(?:\s+[\w\-.:]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[\w\-.:]+))?)*\s*/?>\s*</\1\s*>