Skip to content

Instantly share code, notes, and snippets.

@porqz
porqz / sum.ts
Last active July 24, 2020 09:28
Floating point numbers sum workaround
export default function sum(...numbers: number[]): number {
return numbers.reduce((sum: number, currentNumber: number) => (
(Math.round(sum * 100) + Math.round(currentNumber * 100)) / 100
), 0);
}
import { Directive, HostListener, Input, OnDestroy, OnInit } from '@angular/core';
@Directive({
selector: '[copyToClipboard]'
})
export class CopyToClipboardDirective implements OnInit, OnDestroy {
private static copyableElement: HTMLTextAreaElement;
private static createCopyableElement(): void {
import { Pipe, PipeTransform } from '@angular/core';
interface ParsedPhone {
code: string;
mainPart: string;
}
@Pipe({
name: 'prettifyPhone'
})
@porqz
porqz / slider.js
Last active January 22, 2018 11:59
Simple slider
var Slider = (function($) {
function Slider(options) {
this.viewport = $(options.viewport);
this.leftLink = $(options.leftLink);
this.rightLink = $(options.rightLink);
this.slides = $(options.slides);
this.init();
}
@porqz
porqz / YandexSlovari.rb
Last active May 11, 2017 14:59
Yandex.Slovari and Yandex.Translate API using example
# encoding: UTF-8
require "open-uri"
require "json"
module YandexSlovari
module YAPI
SERVICES = {
dictionary: {
@porqz
porqz / inheritFrom.js
Created May 11, 2017 09:54
Simple JavaScript inheritance implementation (my old code)
(function () {
var defaults = {
defaultsPropertyName: "defaults"
};
/**
* Реализует простое наследование
*
* @param {Function} constructor Функция-конструктор класса-родителя
@porqz
porqz / Block.js
Created May 11, 2017 09:52
Simple BEM implementation (my old code)
/**
* Реализует Блок в терминах БЭМ
*
* @requires jQuery
* @requires ObjectUtils
*
* @param {?String} blockName Имя блока
* @param {?jQuery} block jQuery-представление DOM-элемента блока
*
* @constructor
@porqz
porqz / eslint.commit.hook.sh
Last active May 11, 2017 09:57
ESLint commit hook shell script
#!/bin/zsh
function lintit () {
OUTPUT=$(git diff --name-only | grep -E '(.js)$')
a=("${(f)OUTPUT}")
e=$(eslint -c .eslint.json $a)
echo $e
if [[ "$e" != *"0 problems"* ]]; then
echo "ERROR: Check eslint hints."
exit 1 # reject
Не переносится по дефису слово пин-код.
1. Общие принципы: Use the keyboard, Luke
Упор на горячие клавиши. Мышь — медленно, клавиатура — быстро. Модель GOMS это подтверждает.
Что такое модель GOMS?
Подход к количественному анализу моделей интерфейсов.
Перевод: правила для целей, объектов, методов и выделения (the model of goals, objects, methods and selection rules).
Позволяет предсказать, сколько времени потребуется опытному пользователю на выполнение конкретной операции.
K = 0,2 c — нажатие клавиши;