Skip to content

Instantly share code, notes, and snippets.

View tb's full-sized avatar
🚀
Building High-Performing Software Engineering Teams

Tomasz Bak tb

🚀
Building High-Performing Software Engineering Teams
View GitHub Profile
@bgentry
bgentry / base_connection.rb
Last active May 10, 2019 05:23
graphql-ruby class-based Relay connections + edges, with totalCount field on all connections. Adapted from http://rmosolgo.github.io/blog/2018/04/09/updating-github-to-graphql-1-dot-8-0/
# frozen_string_literal: true
module Types
class BaseConnection < BaseObject
# For some reason these are needed, they call through to the underlying connection wrapper.
extend Forwardable
def_delegators :@object, :cursor_from_node, :parent
# When this class is extended, add the default connection behaviors.
# This adds a new `graphql_name` and description, and searches
@heygrady
heygrady / mapDispatchToProps.md
Last active September 16, 2023 19:19
Redux containers: mapDispatchToProps

Redux containers: mapDispatchToProps

This document details some tips and tricks for creating redux containers. Specifically, this document is looking at the mapDispatchToProps argument of the connect function from [react-redux][react-redux]. There are many ways to write the same thing in redux. This gist covers the various forms that mapDispatchToProps can take.

@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active April 23, 2024 15:35
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@jbaxleyiii
jbaxleyiii / test.js
Created November 15, 2016 19:43
react-apollo testing
import { Component } from "react";
import { print } from "graphql-tag/printer";
import { graphql } from "react-apollo";
import { MockedProvider } from "react-apollo/test-utils";
import { addTypenameToDocument } from "apollo-client/queries/queryTransform";
import { mount } from "enzyme";
import { withSavedPayments, SAVED_ACCTS_QUERY } from "../";
@coleturner
coleturner / camel_case_argument_middleware.rb
Last active February 22, 2018 18:21
Parses camelCase arguments into snake_case for GraphQL Ruby
class CamelCaseMiddleware
def call(parent_type, parent_object, field_definition, field_args, query_context, next_middleware)
next_middleware.call([parent_type, parent_object, field_definition, transform_arguments(field_args), query_context])
end
def transform_arguments(field_args)
transformed_args = {}
types = {}
field_args.each_value do |arg_value|
@tzmartin
tzmartin / embedded-file-viewer.md
Last active April 22, 2024 19:39
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@gund
gund / http-interceptor-concept.md
Last active September 19, 2022 01:08
Concept of Http Interceptor for Angular 2

First, we need to define interfaces with which we will work:

export interface Interceptable<T extends Interceptor<any, any>> {
  addInterceptor(interceptor: T): Interceptable<T>;
  removeInterceptor(interceptor: T): Interceptable<T>;
  clearInterceptors(interceptors?: T[]): Interceptable<T>;
}

export interface Interceptor<T, D> {
// paths and constants
var path = require('path')
var SRC_PATH = path.resolve('./src')
var DIST_PATH = path.resolve('./build')
var OUTPUT_FILENAME = '[name].[chunkhash].js'
var DEV_REGEXP = (/(^babel-?.*|.*-plugin$|.*-loader)/)
var DOT_ENV_SAMPLE_PATH = path.resolve('./.env.default')
var DOT_ENV_PATH = path.resolve('./.env')
var pkg = require('./package.json')
@kkoch986
kkoch986 / MultiSelect.jsx
Last active March 6, 2017 08:58
A MultiSelect prototype for Material UI (v.0.14.4)
/**
* Material UI multi select
*
* Use with:
* <MultiSelect fullWidth={true} value={this.state.values} onChange={(e,v) => this.setState({values: v})}>
* <ListItem primaryText={"Option 1"} value={1} />
* <ListItem primaryText={"Option 2"} value={2} />
* <ListItem primaryText={"Option 3"} value={3} />
* <ListItem primaryText={"Option 4"} value={4} />
* </MultiSelect>
@btroncone
btroncone / rxjs_operators_by_example.md
Last active July 16, 2023 14:57
RxJS 5 Operators By Example