Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖
👨‍💻

Radoslav Stankov RStankov

🤖
👨‍💻
View GitHub Profile
View resources.md
View graphql_utils.ts
import { ApolloClient } from 'apollo-boost';
import { get as lodashGet } from 'lodash';
interface INode<T> {
node: T;
}
interface IHaveNextPage {
pageInfo: {
hasNextPage: boolean;
View eventBus.ts
import * as React from 'react';
import mitt from 'mitt';
type IEventName =
| 'CommentCreated'
| 'CommentDestroy'
type IEventPaload = any;
type IEventHandler = (payload: IEventPaload) => void;
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