Skip to content

Instantly share code, notes, and snippets.

Marius Andra mariusandra

Block or report user

Report or block mariusandra

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 kea-devtools-alpha.js
import React, { useState } from 'react'
import { getContext } from 'kea'
function Connections ({ logic }) {
if (Object.keys(logic.connections).length === 1) {
return null
}
return (
<div style={{ marginTop: 10 }}>
@mariusandra
mariusandra / kea-dimensions.js
Created Sep 12, 2019
dimensions plugin for kea
View kea-dimensions.js
import { setPluginContext, getPluginContext, useMountedLogic } from 'kea'
import { useEffect } from 'react'
/*
usage:
kea({
dimensions: {
// key: [defaultValue, calcFunction]
isSmallScreen: [false, window => window.innerWidth < 640]
View preloaded-state.js
// Plugin to make preloaded state work with kea 1.0
// (pseudocode, not tested, use )
{
name: 'preloadedState',
buildSteps: {
defaults (logic, input) {
const node = getContext().options.preloadedState
if (node) {
// find preLoadedState.[path[0]].[path[1]].etc
View routeset.txt
… actionpack-5.2.0/lib/action_dispatch/routing/route_set.rb:92:in `ActionDispatch::Routing::RouteSet::NamedRouteCollection#clear!' (99 samples - 6.40%) (2 exclusive - 0.13%)
/Users/marius/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/set.rb:336:in `Set#each' (118 samples - 7.63%)
… actionpack-5.2.0/lib/action_dispatch/routing/route_set.rb:92:in `ActionDispatch::Routing::RouteSet::NamedRouteCollection#clear!' (99 samples - 6.40%)
… actionpack-5.2.0/lib/action_dispatch/routing/route_set.rb:443:in `ActionDispatch::Routing::RouteSet#clear!' (100 samples - 6.47%)
… railties-5.2.0/lib/rails/application/routes_reloader.rb:49:in `Rails::Application::RoutesReloader#clear!' (100 samples - 6.47%)
… railties-5.2.0/lib/rails/application/routes_reloader.rb:49:in `Rails::Application::RoutesReloader#clear!' (100 samples - 6.47%)
… railties-5.2.0/lib/rails/application/routes_reloader.rb:18:in `Rails::Application::RoutesReloader#reload!' (1004 samples - 64.94%)
… railties-5.2.0/lib/rails/application/routes_reloader.rb:41:in `Rails::Ap
@mariusandra
mariusandra / slow-rails-reload-development.md
Last active May 15, 2018
Rails development mode memory leak and slowdown, also on new apps
View slow-rails-reload-development.md

This is a draft of an issue I intend to post on the rails/rails repo.

Update: the issue is posted

Hello,

TL;DR; My fairly large Rails app (173 models, 208 controllers) is suffering from a continuously increasing slowdown that makes it hard to work on it. Each reload of the code takes longer than the previous one, with delays increasing to minutes after just a few reloads. I have identified a cause and it's also present on new apps (rails new leaky). No solution yet.

For the past years I've been coping with an issue that Rails feels extremely slow when developing. I start the server, wait for it to boot up and open the site. It takes a minute or two before it loads.

View kea-connected.js
// features-logic.js
import PropTypes from 'prop-types'
import { kea } from 'kea'
export default kea({
actions: () => ({
toggleFeature: (feature) => ({ feature })
}),
reducers: ({ actions }) => ({
features: [{}, PropTypes.object, {
View kea-github.js
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { kea } from 'kea'
import { put, call } from 'redux-saga/effects'
import { delay } from 'redux-saga'
const API_URL = 'https://api.github.com'
@kea({
View counter-kea.js
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { kea } from 'kea'
@kea({
actions: () => ({
increment: (amount) => ({ amount }),
decrement: (amount) => ({ amount })
}),
View counter-setstate.js
import React, { Component } from 'react'
export default class Counter extends Component {
constructor (props) {
this.state = {
counter: 0
}
}
handleIncrement = (amount) => {
You can’t perform that action at this time.