Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖
👨‍💻

Radoslav Stankov RStankov

🤖
👨‍💻
View GitHub Profile
View decorators.tsx
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);
}
View teamplate.rb
module SEO
def self.for(record)
"::SEO::#{record.class_name}".safe_constantize.new(record)
end
end
class SEO::Base
attr_reader :record
def initialize(record)
View jest.config.js
const testPathIgnorePatterns = ['/node_modules/', '.next/', 'graphql/'];
module.exports = {
reporters: ['default', 'jest-junit'],
projects: [
{
runner: 'jest-runner-prettier',
displayName: 'prettier',
moduleFileExtensions: [
'js',
View yarn_upgarde.rb
data = `yarn outdated`
data = data.split("\n")
index = data.find_index { |line| line =~ /^Package.*Current.*/ }
if index.nil?
print "No new dependancies\n"
exit
end
View graph_helper.rb
# frozen_string_literal: true
module SpecSupport
module GraphHelper
def execute_mutation(current_user: nil, context: {}, **inputs)
context = Graph::Context.new(
query: OpenStruct.new(schema: StacksSchema),
values: context.merge(current_user: current_user),
object: nil,
)
View sort_idented_todo_list.js
function buildNode(todo) {
return {
todo,
children: [],
};
}
function buildTree(todos) {
const root = buildNode();
View state_machine.js
/*
Do you use?:
Question
Alternative(product)
Note(product)
Thanks
Add to Stack:
ProductSearch
View draft.tsx
export default miniStateMachine<IComponentProps>({
initialState,
actions,
components: {
search: Search,
newProduct: NewProduct,
product: Poduct,
},
// WIP
View toast.tsx
import Flex from '~/components/Flex';
import Font from '~/components/Font';
import IconClose from './IconClose.svg';
import React from 'react';
import classNames from 'classnames';
import styles from './styles.module.css';
type IToastType = 'notice' | 'success' | 'alert';
type ICloseFn = () => void;
View initApollo.ts
import {
ApolloClient,
InMemoryCache,
HttpLink,
IntrospectionFragmentMatcher,
} from 'apollo-boost';
import { GRAPHQL_URI } from '~/config';
function createClient(initialState: any, { fetch }: { fetch: any }) {
const headers: any = {
You can’t perform that action at this time.