Skip to content

Instantly share code, notes, and snippets.

Juriy Zaytsev kangax

Block or report user

Report or block kangax

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View redux_types.js
import type { GlobalState } from 'redux/modules';
export type ExtractReturn<Fn> = $Call<<T>((...Iterable<any>) => T) => T, Fn>;
// ...
export type BaseAction = $ReadOnly<{ type: string, error?: boolean }>;
// ...
View flow_ts_tests.js
/*
A collection of tests where Flow and TypeScript might have different behavior
Some tests are borrowed from https://github.com/vkurchatkin/typescript-vs-flow
Some tests now have the same behavior as the new versions of Flow/TS have fixed the bugs and improved type safety
*/
/* 1. Accessing unknown properties on objects */
@kangax
kangax / deps_age.js
Last active Feb 27, 2018
Find average age of npm dependencies
View deps_age.js
const fs = require('fs');
const { exec } = require('child_process');
const moment = require('moment');
const _ = require('lodash');
const chalk = require('chalk');
fs.readFile('package.json', (err, data) => {
const { dependencies } = JSON.parse(data.toString());
let totalDays = 0;
View new_tax_bill.js
// https://www.reuters.com/article/us-usa-tax-provisions-factbox/whats-in-the-final-republican-tax-bill-idUSKBN1ED27K
// 10 percent up to $9,525, versus 10 percent up to $9,325 under existing law;
// 12 percent from $9,526 to $38,700, versus 15 percent on $9,326 to $37,950;
// 22 percent on $38,701 to $82,500, versus 25 percent on $37,951 to $91,900;
// 24 percent on $82,501 to $157,500, versus 28 percent on $91,901 to $191,650;
// 32 percent on $157,501 to $200,000, versus 33 percent on $191,651 to $416,700;
// 35 percent on $200,001 to $500,000, versus 35 percent on $416,701 to $418,400;
function calcTax(income) {
@kangax
kangax / backbone.js
Last active Oct 17, 2015
bacon vs. backbone vs. react (just seeing how bacon's paradigm compares with other approaches)
View backbone.js
var RegisterForm = Backbone.View.extend({
ui: {
username: '.username',
fullname: '.fullname',
register: '.register-btn',
loader: '.loader',
feedback: '.feedback'
}
events: {
'input username, fullname': 'onInput',
View meeting_notes.md

Sept 22 2015 Meeting Notes

Allen Wirfs-Brock (AWB), Sebastian Markbage (SM), Jafar Husain (JH), Eric Farriauolo (EF), Caridy Patino (CP), Mark Miller (MM), Adam Klein (AK), Michael Ficarra (MF), Peter Jensen (PJ), Domenic Denicola (DD), Jordan Harband (JHD), Chip Morningstar (CM), Brian Terlson (BT), John Neumann (JN), Dave Herman (DH), Brendan Eich (BE), Rick Waldron (RW), Yehuda Katz (YK), Jeff Morrison (JM), Lee Byron (LB), Daniel Ehrenberg (DE), Ben Smith (BS), Lars Hansen (LH), Nagy Hostafa (NH), Michael Saboff (MS), John Buchanan (JB), Gorkem Yakin (GY), Stefan Penner (SP)

On the phone: Mark Miller (MM), Dan Gohmann (DG), John McCutchan (JMC)

(Need attendance list)

@kangax
kangax / quicksort.hs
Last active Apr 24, 2019
Haskell-inspired quick sort in ES6
View quicksort.hs
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
let smallerSorted = quicksort (filter (<=x) xs)
biggerSorted = quicksort (filter (>x) xs)
in smallerSorted ++ [x] ++ biggerSorted
View backbone.js
var TodoApp = Backbone.View.extend({
template: Handlebars.compile(
'<div>\
<h3>TODO</h3>\
{{#each items}}\
{{ this }}\
{{/each}}\
<form>\
<input value="{{ text }}">\
<button>Add #{{ items.length }}</button>\
View BEM.html
<!--
<component-name>[--modifier-name|__descendent-name]
.component {}
.component__descendant {}
.component--modifier {}
-->
<article class="tweet tweet--is-expanded">
<header class="tweet__header">
View gist:d7cdf7fbe52908a90c47
function formatSchedule(schedules) {
var dayAbbr = [ 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс' ];
function dayIndicesToWord(indices) {
if (areDayIndicesSequential(indices)) {
return dayAbbr[indices[0]] + '-' + dayAbbr[_.last(indices)];
}
else {
var daysAsWords = _.map(indices, function(index) {
return dayAbbr[index];
You can’t perform that action at this time.