Skip to content

Instantly share code, notes, and snippets.

View esamattis's full-sized avatar

Esa-Matti Suuronen esamattis

View GitHub Profile
type DeepReadonly<T> =
T extends [infer A] ? DeepReadonlyObject<[A]> :
T extends [infer A, infer B] ? DeepReadonlyObject<[A, B]> :
T extends [infer A, infer B, infer C] ? DeepReadonlyObject<[A, B, C]> :
T extends [infer A, infer B, infer C, infer D] ? DeepReadonlyObject<[A, B, C, D]> :
T extends [infer A, infer B, infer C, infer D, infer E] ? DeepReadonlyObject<[A, B, C, D, E]> :
T extends [infer A, infer B, infer C, infer D, infer E, infer F] ? DeepReadonlyObject<[A, B, C, D, E, F]> :
T extends [infer A, infer B, infer C, infer D, infer E, infer F, infer G] ? DeepReadonlyObject<[A, B, C, D, E, F, G]> :
T extends (infer A)[] ? DeepReadonlyArray<A> :
T extends Function ? T : // can change to never to forbid functions
@esamattis
esamattis / redux-tree-connector.js
Last active May 11, 2017 09:34 — forked from thevangelist/redux-tree-connector.js
Redux Tree Query HOC with Fallback Values
import React from 'react';
import { connect } from 'react-redux';
import _ from 'lodash';
function reduxConnected(reduxTreeQuery, fallbackValue) {
return WrappedComponent => {
const mapStateToProps = (state) => ({
reduxTreeQuery: _.get(state, reduxTreeQuery, fallbackValue)
});
@esamattis
esamattis / .gitignore
Created September 7, 2016 10:42 — forked from salcode/.gitignore
.gitignore file for WordPress - Bare Minimum Git
# -----------------------------------------------------------------
# .gitignore for WordPress
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20150227
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
curl -XPUT 'http://localhost:9200/_template/template_logstash/' -d '
{
"template": "logstash-*",
"mappings": {
"_default_": {
"_all" : {"enabled" : false}
}
}
}'
@esamattis
esamattis / james.js
Last active December 19, 2015 05:59 — forked from pyykkis/james.js
// james-coffee/index.js
var james = require('james'),
coffee = require('coffee-script'),
fs = require("fs");
coffee.createStream = function() {
return james.createTransformation(function(content, callback) {
// Add header
fs.readFile("header.js", function(err, header) {
  1. Install globally npm install -g profiler
  2. Start your process with node --prof this will create a v8.log file
  3. Build nprof by running /Users/balupton/.nvm/v0.8.12/lib/node_modules/profiler/tools/build-nprof
  4. Run /Users/balupton/.nvm/v0.8.12/lib/node_modules/profiler/nprof this will read the v8.log profile and give you nice ouput