Skip to content

Instantly share code, notes, and snippets.

/* @flow */
// The following three lines are from https://gist.github.com/nmn/b20a92e848c68d88f7fdb8353c71b1ca
type $Object<V> = { +[ key : string] : V }
type $ObjectValues<V, O : $Object<V>> = V
type $Values<O: Object> = $ObjectValues<*, O>
type Enumerables = { [ key : string ] : any }
const UserRoles : Enumerables = {
@zmts
zmts / tokens.md
Last active November 18, 2024 13:13
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@nmn
nmn / $Values.ts
Last active September 11, 2017 10:48
something like $Keys but for values.
// @flow
/*
This magic type will give you the union of the types of all the values in an object type.
This is still far from a fully dynamic $PropertyType, but it's a lot better than just using `any`
*/
/*
Link:
https://flow.org/try/#0C4TwDgpgBAJA8gIwFYQMbADwDUB8UC8UA3gNQDaA1hCAFxQDOwATgJYB2A5gLp1YC+AKFCQoAfRhYAhgBsArhHrYANFDh14yNJlx5CWIeGgSZ8xWtWb0uscbkKMAKhVwcAt8OiIkBYgKhQSVDo2WQBbBAgmJT8AhDpGVk5o-xJJOgQAewzpCEk2aMEBABM0aUkmaAA3cqhaWCk7M2RXAG4ACjqE9g4oAB8oTOzctj6oEPDIgEo3AHoZ9rqAQSYmSRAMcYimHEmoOagAURWMpgYACwyAdxHUE4r0aRAoM8iIATmF4LCt0a7OXf2RyYJ3OVxudy0j2er3e8w6XwmTABM0Ox1O9Au1ygtxWkKeLwqsM+AyyOTyyNRwPRmPBuIe+JhH3hDGY3QpQJBGLB2Ih9OhhKAA
*/
@paulirish
paulirish / what-forces-layout.md
Last active November 15, 2024 16:45
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@mik01aj
mik01aj / README.md
Last active April 21, 2017 13:02
How to use Tether with React

Tether is a great library for positioning stuff (tooltips, modals, hints, etc) in your web app.

But, as I use React, it was pretty problematic for me, as Tether mutates the DOM and React breaks miserably when it sees mutated DOM. The solution is to have the tethered element outside the part of the DOM tree which is controlled by React (in this case, I use document.body).

That's why I created 2 helpers to use Tether with React.

The first one, TetheredElement is a plain JS helper to create a new element, attach it to some other one via Tether, and populate it with some React component.

The second one, TetherTarget is a React component and it uses TetheredElement to integrate it further with React, so that you can attach components to each other with Tether, without leaving the cozy React/JSX world and worrying about manual DOM operations. Just write:

@yoavniran
yoavniran / ultimate-ut-cheat-sheet.md
Last active October 1, 2024 17:10
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
@listochkin
listochkin / gitter-dev-ua-faq.md
Last active April 27, 2021 15:59
Gitter Dev-UA FAQ

FAQ по Gitter-чатам группы Dev-UA

Так получилось, что мы открываем сейчас достаточно много чатов в [Gitter.im][1]: часто это совсем новые для нас сообщества (как [PHP-чат][2], например), а часто - это уже существующие чаты, которые мы создали и администрировали в Skype (например, [Frontend-UA][3]). Не зависимо от того, новый ли это чат или "переезжающий", нам раз за разом задают одни и те же вопросы. Здесь мы собрали их и подготовили несколько ответов.

Почему Gitter?

  1. Больше 300 человек в чате (это лимит в Skype)
@zerkalica
zerkalica / build-geppetto.sh
Created November 29, 2012 22:34
geppetto jam package builder
#!/bin/sh
sdir=$(pwd)
[ -e $sdir/$(basename $0) ] || sdir=$(dirname $0)
[ -d $sdir/lib ] || mkdir -p $sdir/lib
wget "https://raw.github.com/ModelN/backbone.geppetto/master/backbone.geppetto.js" -O $sdir/lib/backbone.geppetto.js
wget "https://raw.github.com/ModelN/backbone.geppetto/master/README.md" -O $sdir/readme.md
@dex4er
dex4er / eToken-9.sh
Last active August 2, 2024 15:31
eToken
# udev
wget https://gist.githubusercontent.com/dex4er/1354710/raw/0f9738c7439cdfb9e4446663d137f91ee153b4d8/etc_udev_rules.d_90-hid-eToken.rules
sudo cp etc_udev_rules.d_90-hid-eToken.rules /etc/udev/rules.d
sudo service udev reload
# required packages
sudo apt-get -yy install pcscd opensc
# legacy library
wget http://mirrors.kernel.org/ubuntu/pool/universe/h/hal/libhal1_0.5.14-8_amd64.deb