Skip to content

Instantly share code, notes, and snippets.

@tesmen
tesmen / gist:ea520685eca1a9d387a5c37e25e321b0
Last active March 31, 2022 16:56
Simple binary search
/* eslint-disable */
class VelocityChecker {
arrayData = []
iterationsCount = 0
from
to
constructor(from, to) {
this.from = from
this.to = to
.bs-callout {
padding: 20px;
margin: 20px 0;
border: 1px solid #eee;
border-left-width: 5px;
border-radius: 3px;
}
.bs-callout h4 {
margin-top: 0;
margin-bottom: 5px;
function declension(amount, words) {
var digit = (Number(amount) > 20) ? Number(amount) % 10 : Number(amount);
if (digit >= 5 || digit == 0) {
return words[2]
}
if (digit >= 2) {
return words[1]
}
function triple(nStr) { // деление на разряды пробелами 132456789 -> 123 456 789
nStr += '';
var x = nStr.split('.');
var x1 = x[0];
var x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ' ' + '$2');
}
@tesmen
tesmen / strong-passwords.php
Created October 2, 2015 09:12 — forked from tylerhall/strong-passwords.php
A user friendly, strong password generator PHP function.
<?PHP
// Generates a strong password of N length containing at least one lower case letter,
// one uppercase letter, one digit, and one special character. The remaining characters
// in the password are chosen at random from those four sets.
//
// The available characters in each set are user friendly - there are no ambiguous
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option,
// makes it much easier for users to manually type or speak their passwords.
//
// Note: the $add_dashes option will increase the length of the password by