Skip to content

Instantly share code, notes, and snippets.

View RStankov's full-sized avatar
🤖
👨‍💻

Radoslav Stankov RStankov

🤖
👨‍💻
View GitHub Profile
@RStankov
RStankov / container.tsx
Created February 21, 2024 21:22
Modal System
// The most complex part of the modal system
// There are lot of small details heres
// I extracted this from a real project
// Notice: Hooks hide a lot of complexity
import { IModalOpen } from './types';
import { closeModal } from './triggers';
import { useEffect, useMemo, useRef, useState } from 'react';
import { useEventBus } from '../eventBus';
import { InsideModalProvider } from './context';
import * as React from 'react';
import mitt from 'mitt';
interface IEventsMap {
modalOpen: {
content: React.ReactNode;
url?: string;
};
modalClose: null;
class Controller < ActionController::Base
include DevelopmentLogging if Rails.env.development?
end
# frozen_string_literal: true
# Complex counter counter caches
#
# Usage:
#
# In parent model
# class Post < ApplicationRecord
# ExplicitCounterCache.define(self, votes_count, -> { votes.active })
# ExplicitCounterCache.define(self, comments_count, -> { votes.visible })
# frozen_string_literal: true
# Note(rstankov):
#
# **Don't use for `connection`s, only for `field` attributes**
#
# Preload associations.
#
# Supports all preload formats from [ActiveRecord::Base.includes](https://api.rubyonrails.org/v5.2.4/classes/ActiveRecord/QueryMethods.html#method-i-includes).
#

We are searching for Team Lead to work with product managers, designers, and engineers to shape product direction and deliver great features.

Your responsibilities will include

  • Managing and mentoring your fellow engineers
  • Collaborating closely with product and designer to ship great products
  • Driving your team roadmap, from conception to production
  • Leveraging research and usage data to iterate on these products
  • Brainstorming architecture and product decisions with the team.

How would you spend your time

import { ApolloClient } from 'apollo-boost';
import { get as lodashGet } from 'lodash';
interface INode<T> {
node: T;
}
interface IHaveNextPage {
pageInfo: {
hasNextPage: boolean;
import * as React from 'react';
import mitt from 'mitt';
type IEventName =
| 'CommentCreated'
| 'CommentDestroy'
type IEventPaload = any;
type IEventHandler = (payload: IEventPaload) => void;
@RStankov
RStankov / decorators.tsx
Created October 22, 2020 19:02
Draft.js Markdown
import * as React from 'react';
const BOLD_REGEX = /(^|[^\w])\*\*[^\*]+\*\*($|[^\w])/gi;
const ITALIC_REGEX = /(^|[^\w])(^|[^\*])\*[^\*]+\*($|[^\w])/gi;
const UNDERLINE_REGEX = /(^|[^\w])(^|[^\~])\~[^\~]+\~($|[^\w])/gi;
const STIKE_REGEX = /(^|[^\w])\~\~[^\~]+\~\~($|[^\w])/gi;
function boldStrategy(contentBlock: any, callback: any, _contentState: any) {
findWithRegex(BOLD_REGEX, contentBlock, callback);
}