Skip to content

Instantly share code, notes, and snippets.

View vdanchenkov's full-sized avatar

Vladimir Danchenkov vdanchenkov

View GitHub Profile
@vdanchenkov
vdanchenkov / rescript.json
Last active February 6, 2022 15:09
My vscode snippets for rescript, recoil
{
"className": {
"prefix": ["cn", "tw"],
"body": "className=\"$0\""
},
"className conditional": {
"prefix": "cnn",
"body": "className={cx([\"$0\"])}"
},
"React Component": {
@vdanchenkov
vdanchenkov / gist:ea2c98a7e88b3ab16362bdf390a1dc9e
Created April 18, 2018 05:18
Large networks blocked in Russia on 18.04.2018.
13.125.0.0/16
13.56.0.0/14
18.130.0.0/16
18.184.0.0/15
18.194.0.0/15
18.196.0.0/15
34.192.0.0/10
34.240.0.0/13
34.248.0.0/13
35.156.0.0/14
@vdanchenkov
vdanchenkov / syncSearchUsage.js
Last active October 1, 2016 22:56
samples for wtf article
const lodash = require('lodash')
const wtf = require('wtf')
const print = ({ result, display }) => console.log(`${result} ≈ ${display}`)
wtf.sync({ lodash },
['apple', 'p'], true,
['apple', 'x'], false
).map(print)
@vdanchenkov
vdanchenkov / logg.js
Last active September 25, 2016 00:04
console.logg = (...args) => {
args.forEach(arg => {
if (arg !== null && typeof arg === 'object' && !Array.isArray(arg)) {
Object.keys(arg).forEach(propName => {
console.log(`\u001b[7m${propName}:\u001b[27m`)
console.log(arg[propName])
})
} else {
console.log(arg)
}
@vdanchenkov
vdanchenkov / index.js
Last active September 17, 2016 00:28
Chrome Canary eats your stack due to tail call optimization http://www.2ality.com/2015/06/tail-call-optimization.html
(function () {
"use strict"
const a = () => '' + b()
const b = () => c()
const c = () => d()
const d = () => new Error().stack
console.log(a())
})()
@vdanchenkov
vdanchenkov / index.js
Created September 14, 2016 00:02
Might be useful for glamor... Or not... https://github.com/threepointone/glamor
const doSomething = () => {}
const S = (...args) => {
const [ Component, css, defaultProps ] =
typeof args[0] === 'string' ? args : [ 'div', ...args ]
return (props) => <Component css={css} {...defaultProps} {...props}/>
}
const Label = S('label', { display: 'block' })
const Block = S({ margin: '1rem 0' })
@vdanchenkov
vdanchenkov / worker.js
Created July 6, 2016 12:29
simple amd loader
import zipObject from 'lodash/zipObject'
import memoize from 'lodash/memoize'
const loadModules = memoize((modules) => {
// prevent node style export
const exports = undefined
const module = undefined
const resultModules = []
const resultNames = []
@vdanchenkov
vdanchenkov / current_user_header.js
Created March 28, 2016 11:39 — forked from st8998/header.js
Container component with loading
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { find, propEq } from 'ramda'
import Header from './header'
import { requestCurrent as requestCurrentUser } from 'users/users_actions'
@connect(
state => ({ currentUser: find(propEq('current', 1), state.users) }),
{ requestCurrentUser }
)
@vdanchenkov
vdanchenkov / createAction.js
Last active March 24, 2016 21:04
You probably do not need redux-act to reduce boilerplate
const createAction = (type, payloadReducer = (i => i)) => {
const creator = (...args) => {
const payload = payloadReducer(...args);
return payload ? { type, payload } : { type };
};
creator.toString = () => type;
return creator;
}