This file contains 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
@echo off | |
:: Get start timestamp | |
set _time=%time% | |
set _hours=100%_time:~0,2%%%100 | |
set _min=100%_time:~3,2%%%100 | |
set _sec=100%_time:~6,2%%%100 | |
set _cs=%_time:~9,2% | |
set /a _started=_hours*60*60*100+_min*60*100+_sec*100+_cs |
This file contains 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
// Rules: At leasst 1 uppercase, 1 lowercase, 1 digit, 1 special char from z85 alphabet | |
// Test: http://regex101.com/r/yP9aU6/1 | |
function validateResult(string) { | |
var regex = (/^(?=\S*?\w)(?=\S*?\d)(?=\S*?[.\-:+=^!\/*?&<>()\[\]{}@%$#])[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.\-:+=^!/*?&<>()\[\]{}@%$#]+$/gm); | |
return regex.test(string); | |
} |
This file contains 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
// Maxdamntus.forEach | |
function dedupString(string) { | |
var acc = { | |
str: "", | |
map: {} | |
}; | |
Array.prototype.forEach.call(string, function(char) { | |
if (!acc.map[char.toLowerCase()]) acc.str += char; | |
acc.map[char.toLowerCase()] = true; | |
}); |
This file contains 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 saltedShuffle(alphabet, salt) { | |
var integer, j, temp, i, v, p; | |
for (i = alphabet.length - 1, v = 0, p = 0; i > 0; i--, v++) { | |
v %= salt.length; | |
p += integer = salt[v].charCodeAt(0); | |
j = (integer + v + p) % i; | |
temp = alphabet[j]; | |
alphabet = alphabet.substr(0, j) + alphabet[i] + alphabet.substr(j + 1); | |
alphabet = alphabet.substr(0, i) + temp + alphabet.substr(i + 1); | |
} |
This file contains 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
// <a href="javascript: ... ">Open</a> | |
function post_to_url(url, params) { | |
var form = document.createElement('form'); | |
form.action = url; | |
form.method = 'POST'; | |
for (var i in params) { | |
if (params.hasOwnProperty(i)) { | |
var input = document.createElement('input'); | |
input.type = 'hidden'; |
This file contains 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 Uint8Array2hex(arr) { | |
var hexEncodeArray = '0123456789abcdef'.split(''); | |
var s = ''; | |
for (var i = 0; i < arr.length; i++) { | |
var code = arr[i]; | |
s += hexEncodeArray[code >>> 4]; | |
s += hexEncodeArray[code & 0x0F]; | |
} | |
return s; | |
} |
This file contains 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
var x = "ляляфа"; | |
var y = unescape(encodeURIComponent(x)); | |
var z = decodeURIComponent(escape(y)); | |
// alternative | |
var UTF8 = { | |
encode: function(string) { | |
string = string.replace(/\r\n/g, "\n"); | |
var utftext = ""; | |
for (var n = 0; n < string.length; n++) { |
This file contains 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 () { | |
var alphabet = '0123456789abcdefghjkmnpqrtuvwxyz'; | |
var alias = { | |
o: 0, | |
i: 1, | |
l: 1, | |
s: 5 | |
}; | |
var lookup = function () { | |
var table = {}; |
This file contains 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
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then | |
// use window.btoa' step. According to my tests, this appears to be a faster approach: | |
// http://jsperf.com/encoding-xhr-image-data/5 | |
function base64ArrayBuffer(arrayBuffer) { | |
var base64 = ''; | |
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | |
var bytes = new Uint8Array(arrayBuffer); | |
var byteLength = bytes.byteLength; | |
var byteRemainder = byteLength % 3; |
This file contains 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 getByteCount(s) { | |
var count = 0, | |
stringLength = s.length, | |
i; | |
s = String(s || ""); | |
for (i = 0; i < stringLength; i++) { | |
var partCount = encodeURI(s[i]).split("%").length; | |
count += partCount == 1 ? 1 : partCount - 1; | |
} | |
return count; |
NewerOlder