Skip to content

Instantly share code, notes, and snippets.

@chudnyi
chudnyi / react-lifecycle-cheatsheet.md
Created April 19, 2019 10:30 — forked from bvaughn/react-lifecycle-cheatsheet.md
React lifecycle cheatsheet

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps Update state based on changed props
@chudnyi
chudnyi / metro.config.js
Created April 15, 2019 08:57 — forked from mbret/metro.config.js
Symlink for React Native 0.59 (symlink + scoped package + hast name collision)
/* eslint no-useless-escape: 0 */
/* eslint max-len: 0 */
/**
* For more info regarding metro config:
* @see https://facebook.github.io/metro/docs/en/configuration
*/
const path = require("path");
const fs = require("fs");
// Get blacklist factory
@chudnyi
chudnyi / pin256.sh
Created April 12, 2019 12:45 — forked from 0xced/pin256.sh
Extract certificate + public key + pin from a TLS server
#!/usr/bin/env bash -e
HOST=${1:-cloudflare.com}
FILENAME=${2:-${HOST%%.*}}
# For file naming, see https://support.ssl.com/Knowledgebase/Article/View/19/0/der-vs-crt-vs-cer-vs-pem-certificates-and-how-to-convert-them
# For HTTP Public Key Pinning (HPKP), see https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning
CERTIFICATE_PEM="${FILENAME}_certificate.ascii.crt"
CERTIFICATE_DER="${FILENAME}_certificate.crt"
PUBKEY_PEM="${FILENAME}_pubkey.ascii.key"
@chudnyi
chudnyi / ViewController.Swift
Created April 9, 2019 06:45 — forked from cscouto/ViewController.Swift
SWIFT - Observe contentSize fro the tableView
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var heightTableView: NSLayoutConstraint!
override func viewDidLoad() {
super.viewDidLoad()
tableView.addObserver(self, forKeyPath: "contentSize", options: .new, context: nil)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
@chudnyi
chudnyi / wait_for_http_200.sh
Created April 2, 2019 18:22 — forked from rgl/wait_for_http_200.sh
Wait for an HTTP endpoint to return 200 OK with Bash and curl
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9000)" != "200" ]]; do sleep 5; done'
# also check https://gist.github.com/rgl/c2ba64b7e2a5a04d1eb65983995dce76
@chudnyi
chudnyi / curl.md
Created March 24, 2019 14:48 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@chudnyi
chudnyi / tokens.md
Created January 25, 2019 08:44 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Preconditions:

В данной заметке рассматривается работа JWT с симметичным алгоритмом шифрования (HS256/HS384/HS512)

Основы:

Аутентификация(authentication, от греч. αὐθεντικός [authentikos] – реальный, подлинный; от αὐθέντης [authentes] – автор) - это процесс проверки учётных данных пользователя (логин/пароль). Проверка подлинности пользователя путём сравнения введённого им логина/пароля с данными сохранёнными в базе данных.

Авторизация(authorization — разрешение, уполномочивание) - это проверка прав пользователя на доступ к определенным ресурсам.

@chudnyi
chudnyi / postgres-brew.md
Created January 8, 2019 09:04 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@chudnyi
chudnyi / index.ts
Created November 26, 2018 13:43 — forked from MichalLytek/index.ts
ESNext Async Generators Demo [TypeScript]
// define shim for node.js
(Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol.for("Symbol.asyncIterator");
// helpers
function sleep(ms: number) {
return new Promise<void>(resolve => setTimeout(resolve, ms));
}
async function returnAfter<T>(time: number, value: T) {
await sleep(time);
return value;