Skip to content

Instantly share code, notes, and snippets.

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

Radoslav Stankov RStankov

🤖
👨‍💻
View GitHub Profile
# frozen_string_literal: true
# NOTE(rstankov): styles ignored intentionally
files = %w(components routes utils layouts hooks).map { |dir| Dir["frontend/#{dir}/**/*.css"] }.flatten
files.each do |file|
next if file.end_with?('.module.css')
`git mv #{file} #{file.gsub('.css', '.module.css')}`
`git mv #{file + '.d.ts'} #{file.gsub('.css', '.module.css.d.ts')}`
module SpecSupport
module GraphHelper
def execute_mutation(current_user: nil, context: {}, **inputs)
context = Graph::Context.new(
query: OpenStruct.new(schema: YourSchema),
values: context.merge(current_user: current_user),
object: nil,
)
described_class.new(object: nil, context: context, field: nil).resolve(inputs)
end
# frozen_string_literal: true
require 'csv'
require 'ostruct'
require 'prettyprint'
users = {}
CSV.foreach('data.csv', headers: true) do |row|
users[row['id'].to_i] = row['friend_ids'].gsub('{', '').gsub('}', '').split(',').map(&:to_i)
end
// profiles/[slug]/index.tsx
import dynamic from 'next/dynamic';
import featureSwitch from '~/utls/featureSwitch';
const page = dynamic(() => import('~/routes/profiles/show'), {
loading: () => null,
}) as any;
const legacy = dynamic(() => import('~/routes/profiles/legacy-show'), {
loading: () => null,
@RStankov
RStankov / README.md
Last active November 3, 2019 11:05
GraphQL Tracer

Scope

Tracking performance for GraphQL in development is quite hard.

I'm using the Apollo Tracing format here. Unfortunately there isn't a good viewer for the information from there. It also doesn't include SQL/Cache information.

Features:

  • Viewer for tracing information
  • Store tracing information on disk, for future reference
<%= newsletter_section @digest.trending do |data, section| %>
<% section.title 'Trending products this week' %>
<% section.thumbnail do %>
<%= newsletter_mosaic data.profiles %>
<% end %>
<% section.content do %>
<%= newsletter_links data.profiles %> were the most popular products last week.
<% end %>
<% end %>
# frozen_string_literal: true
module Handle::NetworkErrors
extend self
ERRORS = [
EOFError,
Errno::ECONNREFUSED,
Errno::ECONNRESET,
Errno::EFAULT,
@RStankov
RStankov / learn.md
Last active December 11, 2020 15:28
import * as React from 'react';
import { CREATE_MUTATION, DESTROY_MUTATION } from './Mutation';
import MutationButton, {
IProps as IButtonProps,
} from '~/components/MutationButton';
import { polymorphicInput } from '~/utils/graphql';
import { FollowButtonFragment } from '~/graphql/types';
import useViewerProfile from '~/hooks/useViewerProfile';
type Subject = FollowButtonFragment & {
class Comment < ApplicationRecord
belong_to user
scope, :recent, (count = 3) -> { joins(RECENT_SQL).where('rankings.rank < ?', count.next).order(id: :desc) }
RECENT_SQL = <<-SQL
INNER JOIN (
SELECT
id,
RANK() OVER(PARTITION BY post_id ORDER BY id DESC) rank