This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useEffect, useState } from "react"; | |
| type UseTextSelectionReturn = { | |
| text: string; | |
| rects: DOMRect[]; | |
| ranges: Range[]; | |
| selection: Selection | null; | |
| }; | |
| const getRangesFromSelection = (selection: Selection): Range[] => { |
This algorithm returns the points that form an orthogonal path between two rectangles.
// Define shapes
const shapeA = {left: 50, top: 50, width: 100, height: 100};
const shapeB = {left: 200, top: 200, width: 50, height: 100};
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as React from "react"; | |
| import { useMousePosition } from "~/hooks/useMousePosition"; | |
| /** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */ | |
| export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) { | |
| const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {}; | |
| const [mouseX, mouseY] = useMousePosition(); | |
| const positions = { x, y, h, w, mouseX, mouseY }; | |
| return ( | |
| <div |
Moved to Shopify/graphql-design-tutorial
- Blog
- How to GraphQL - Ruby (Tutorial)
- Speaker deck
| Date | Event | Title | Slides | Video | Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Types::FoosType = GraphQL::ObjectType.define do | |
| field :foos, !types[Types::FooType] do | |
| timed true # enable New Relic trace_execution_scoped | |
| description "Returns foos" | |
| argument :per, types.Int, default_value: 20 | |
| argument :page, types.Int, default_value: 1 | |
| # Moving to cursor pagination would be better | |
| resolve(...) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FileUploadComponent extends Component{ | |
| upload(){ | |
| this.props.mutate({ | |
| variables: { | |
| id, | |
| avatar: this.inputFile.files[0] //this is how you send file | |
| } | |
| }). | |
| then(({data}) => { | |
| console.log(data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # NewRelic instrumenter for GraphQL-ruby | |
| # | |
| # In your controller: | |
| # ::NewRelic::Agent.add_custom_attributes({ | |
| # user_id: @user.try(:id), | |
| # query_string: @query_string, | |
| # query_arguments: @query_variables | |
| # }) | |
| # | |
| # @document = self.class.trace_execution_scoped(["GraphQL#parse"]) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import {withIntl} from 'ufleet-intl'; | |
| const Example = (props) => <div>{props.t('Hello, {name}', {name: 'React'})}</div>; | |
| export default withIntl(Example); |
NewerOlder