Skip to content

Instantly share code, notes, and snippets.

@Mesqalito
Mesqalito / browserDetectNav.js
Last active December 30, 2015 22:29
Detect browser by userAgent string
function browserDetectNav() {
var ua = window.navigator.userAgent;
var operaRe = /(Opera|OPR)[\/ ]([\w.\/]+)/i;
var chromeRe = /(Chrome)\/([\w.\/]+)/i;
var safariRe = /(Safari)\/([\w.\/]+)/i; // must not contain 'Chrome'
var firefoxRe = /(Firefox)\/([\w.\/]+)/i; // mus not contain 'Opera'
var ieRe = /(?:(MSIE) |(Trident)\/.+rv:)([\w.]+)/i; // must not contain 'Opera'
var versionRe = /(Version)\/([\w.\/]+)/i; // match for browser version
var versionSplit = /[\/\.]/i;
// WARNING! Order is important here!
@Mesqalito
Mesqalito / gist:6816113
Last active December 24, 2015 14:59
Simple Store
var Store = function() {
var data = {};
var keys = [];
return {
add: function(key, value) {
if (keys.indexOf(key) === -1) {
keys.push(key);
data[key] = value;
return true;
}
@Mesqalito
Mesqalito / gist:835118
Created February 19, 2011 15:18
WSH JS RegEx Replacer
var fileName = "Web.config";
var number = 17;
var fso, fs;
fso = new ActiveXObject("Scripting.FileSystemObject");
fs = fso.OpenTextFile(fileName, 1);
var text = fs.ReadAll();
var textMod = text.replace(new RegExp("(<add[\\s\\S]*maxInvalidPasswordAttempts=\")[^\"]*(\\\"[^>]*>)"), "$1" + number + "$2");
WScript.Echo(textMod);
@Mesqalito
Mesqalito / gist:835080
Created February 19, 2011 14:22
Web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices"
@Mesqalito
Mesqalito / gist:790930
Created January 22, 2011 06:32
WSH Random as ChangeOrder
// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\marc2003\v2\common.js"
// @import "%fb2k_path%scripts\marc2003\v2\tooltip_buttons.js"
// ==/PREPROCESSOR==
var bw = 24;
var bh = 20;
var top_margin = 0;
var left_margin = 0;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Mesqalito
Mesqalito / gist:788967
Created January 20, 2011 23:52
WSH PanelMod Cut
//Modified by Mesqalito v4
// Flags, used with GdiDrawText
// For more information, see: http://msdn.microsoft.com/en-us/library/dd162498(VS.85).aspx
var DT_TOP = 0x00000000;
var DT_LEFT = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_RIGHT = 0x00000002;
var DT_VCENTER = 0x00000004;
var DT_BOTTOM = 0x00000008;
var DT_WORDBREAK = 0x00000010;