Skip to content

Instantly share code, notes, and snippets.

View sompylasar's full-sized avatar

Ivan Babak sompylasar

View GitHub Profile
#!/bin/bash
set -eu
REPO_PATH=$1
if [[ ! -d "${REPO_PATH}" ]]; then
exit -1
fi
diff --git a/frontend/DataView/DataView.js b/frontend/DataView/DataView.js
index 1a7fd1a..ba35cc4 100644
--- a/frontend/DataView/DataView.js
+++ b/frontend/DataView/DataView.js
@@ -32,6 +32,7 @@ type DataViewProps = {
startOpen?: boolean,
noSort?: boolean,
readOnly?: boolean,
+ themeKind?: 'props' | 'state',
};
@sompylasar
sompylasar / todo-md-generator.js
Created April 9, 2018 23:51
TODO.md generator
#!/usr/bin/env node
/* eslint-disable strict, no-console, prefer-arrow-callback, prefer-spread */
'use strict';
const glob = require('glob');
const leasot = require('leasot'); // eslint-disable-line import/no-extraneous-dependencies
const path = require('path');
const fs = require('fs');
const gitAdd = require('../_binUtils').gitAdd;
@sompylasar
sompylasar / Cypress.Commands.getVisuallyBelow.js
Created April 6, 2018 00:13
Cypress custom command that finds a visible element rendered visually below the previous subject. Using it to find inputs below labels that miss accessible identifiers. https://twitter.com/sompylasar/status/982027453764792320
// `queries.matches` is this function: https://github.com/kentcdodds/testing-workshop/blob/888201516879d067adddc6b6dd3c76394f0b2bee/cypress/support/queries.js#L74-L82
Cypress.Commands.add('getVisuallyBelow', { prevSubject: 'element' }, (subject, matcher) => {
const domNode = subject.get(0);
const log = Cypress.log({
name: 'GET_VISUALLY_BELOW',
message: '' + (
String(
domNode.nodeName +
@sompylasar
sompylasar / ZIndexManager.js
Last active February 28, 2018 23:44
ZIndexManager – Stores and manages z-indexes in a stacking order. ZIndexManagerProvider – provides ZIndexManager functions via React context. Refs: https://hackernoon.com/my-approach-to-using-z-index-eca67feb079c
/**
* ZIndexManager
*
* Stores and manages z-indexes in a stacking order.
*/
export default class ZIndexManager {
constructor(onChange) {
this._zIndexMin = 99;
this._zIndexes = {};
this._zIndexMax = this._zIndexMin;
const jestDiff = require('jest-diff'); // should be jest-diff@22.1.0
function jestDiffAndPrint(a, b) {
console.log(
'----------- a:\n' +
a +
'\n----------- b:\n' +
b +
'\n----------- diff:\n' +
jestDiff(a, b) +
@sompylasar
sompylasar / cjs-jira-favicon-per-project.js
Created January 19, 2018 20:52
Sync JIRA favicon with the icon for the currently opened project.
// Custom JavaScript for websites: https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija?hl=en
// NOTE(@sompylasar): Doesn't work for the default project icons because they are in SVG, and link rel "shortcut icon" doesn't seem to accept SVGs.
(function () {
var iconEl = window.document.querySelector('link[rel="shortcut icon"]');
if (!iconEl) { return; }
var defaultSrc = iconEl.getAttribute('href');
var observer;
var timer;
var update = function () {
var imageEl = window.document.querySelector('[src^="' + window.location.origin + '/secure/projectavatar?"]');
@sompylasar
sompylasar / Fahrenheit.md
Created January 19, 2018 19:56
"Cold" is a relative term. Use the handy list below to overcome the confusion. Degrees (Fahrenheit)

"Cold" is a relative term. Use the handy list below to overcome the confusion. Degrees (Fahrenheit)

65

  • Hawaiians declare a two-blanket night

60

  • Californians put on sweaters (if they can find one)

50

  • Miami residents turn on the heat

45

  • Vermont residents go to outdoor concerts
@sompylasar
sompylasar / hoistRedditImages.js
Last active January 15, 2018 01:08
Avoid clicking every subreddit to view the full image at https://www.reddit.com/r/ColorizedHistory/
// Avoid clicking every subreddit to view the full image, for example, at https://www.reddit.com/r/ColorizedHistory/
// Run the following code via the Chrome DevTools Console in the top frame of the Reddit page.
(function hoistRedditImages() {
Promise.all(
[].slice
.call(document.querySelectorAll("#siteTable a[data-href-url]"))
.map(el => {
if (document.querySelectorAll(".hoistRedditImages").length) {
return;
}
@sompylasar
sompylasar / ReduxClockProvider.js
Created December 8, 2017 23:43
Pure clock state with React, Redux, Redux-Saga. Do not use `Date.now()` or `new Date()` or `moment()` in `render()`, reading the current clock state is not pure (returns different values on each call). https://twitter.com/acdlite/status/939260579247562752
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import {
extractClockTimestamp,
} from './reduxClockReducer';
import {
ACTION_CLOCK_SUBSCRIBE,