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
<script> | |
function loadWebFont(isLoaded) { | |
if (isLoaded = 'undefined' !== typeof WebFont) { | |
WebFont.load({ google: { families: ["Lato:100,100italic,300,300italic,400,400italic,700,700italic,900,900italic","Montserrat:100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic","Oswald:200,300,400,500,600,700","Great Vibes:400","Poppins:100,200,300,regular,500,600,700,800,900"] }}); | |
} | |
return isLoaded; | |
} | |
if (!loadWebFont()) { // if WebFont not available yet... | |
// wait until HTML is fully loaded |
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() { | |
// const | |
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', | |
base = 62; | |
window.int62 = function(int) { | |
if (0 === int) { | |
return '0'; | |
} |
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
<?php | |
$data_to_post = [ | |
'username' => 'user@email', | |
'password' => '', // not specified in this demo | |
//'start' => 0, | |
//'number_to_return' => 2, | |
//'gid' => 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
// Check, whether string is a numerical value in “scientific notation” format. | |
function is_scientific_notation($str) { | |
return !is_int($str) && !is_float($str) && is_numeric($str) | |
&& stripos($str, 'e') !== false; | |
} |
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
const exportToCsv = (data, csvFileName) => { | |
const link = document.createElement("a"); | |
if (undefined !== link.download) { // downloads supported? | |
const csvRows = [], | |
// get the key names for the CSV header (column names) | |
headers = Object.keys(data[0]), | |
escCsvValue = value => "string" === typeof value && (-1 !== value.indexOf('"') || -1 !== value.indexOf(",")) // escape values that contain quotes or commas | |
? '"' + value.replace(/"/g, '""') + '"' // Dobule quotes are double escaped |
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
Convert UTF-8 to Windows-1251 | |
utf8ToWin1251 = s => { | |
const map1251 = { 1027: 129, 8225: 135, 1046: 198, 8222: 132, 1047: 199, 1168: 165, 1048: 200, 1113: 154, 1049: 201, 1045: 197, 1050: 202, 1028: 170, 160: 160, 1040: 192, 1051: 203, 164: 164, 166: 166, 167: 167, 169: 169, 171: 171, 172: 172, 173: 173, 174: 174, 1053: 205, 176: 176, 177: 177, 1114: 156, 181: 181, 182: 182, 183: 183, 8221: 148, 187: 187, 1029: 189, 1056: 208, 1057: 209, 1058: 210, 8364: 136, 1112: 188, 1115: 158, 1059: 211, 1060: 212, 1030: 178, 1061: 213, 1062: 214, 1063: 215, 1116: 157, 1064: 216, 1065: 217, 1031: 175, 1066: 218, 1067: 219, 1068: 220, 1069: 221, 1070: 222, 1032: 163, 8226: 149, 1071: 223, 1072: 224, 8482: 153, 1073: 225, 8240: 137, 1118: 162, 1074: 226, 1110: 179, 8230: 133, 1075: 227, 1033: 138, 1076: 228, 1077: 229, 8211: 150, 1078: 230, 1119: 159, 1079: 231, 1042: 194, 1080: 232, 1034: 140, 1025: 168, 1081: 233, 1082: 234, 8212: 151, 1083: 235, 1169: 180, 1084: 236, 1052: 204, 1085: 237, 1035: 142, 1086: 238, 1087: 2 |
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
(async () => { | |
const puppeteer = require('puppeteer'), | |
fs = require('fs').promises, | |
// Generate 2-letter combinations | |
generateCombinations = x => { | |
const combinations = [], | |
// Small latin letters and digits | |
characters = [...Array(26).keys()].map(i => String.fromCharCode(i + 97)) | |
.concat([...Array(10).keys()].map(i => i.toString())); |
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(window) { | |
// lStorage & sStorage -- replacements for localStorage and sessionStorage | |
// =========================== | |
// Brave browser (withe default settings) is blocking access to localStorage. | |
// This is sucks, but in most cases we can live without stored data. Just don't let exception prevent execution of our code. | |
// =========================== | |
/* IDEA: | |
* We have replacement for any storage, that lives only during current instance. (Even less than session.) | |
* We use this replacement only if regular storage not found. (And this is the only sense to use it.) |
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
// see also is_valid_email() in "strings.php". | |
String.prototype.isValidEmail = function() { | |
// This all are valid accordingly to RFC: !#$%&'*+-/=?^_`{|}~ | |
// Gmail use + for subadressing. Usage of other special chars in unknown, but they are still valid anyway. | |
// Double-dot, however (..) is not allowed. | |
return 0 <= this.indexOf("..") | |
? false // email can't have 2 dots at row | |
: /^([\w!#$%&'*+\-/=?^_`{|}~]+(?:\.[\w!#$%&'*+\-/=?^_`{|}~]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,30}(?:\.[a-z]{2})?)$/i.test(this.trim()); // the longest domain extension in 2015 was ".cancerresearch", and looks like it's not the limit. UPD. how about .travelersinsurance? I set up it the longest domain extension to 30 chars. | |
} |
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
:: See also set-wallpaper.bat | |
@echo off | |
if [%1]==[] ( | |
echo USAGE: set-background-color.bat [6 hexadecimal digit color value] | |
echo EXAMPLE: "set-background-color.bat ffffff". This will set background color to white. | |
exit | |
) |
NewerOlder