Skip to content

Instantly share code, notes, and snippets.

Avatar

Andy Edwards jedwards1211

View GitHub Profile
@jedwards1211
jedwards1211 / createApolloServer.js
Created Jan 15, 2020
installSubscriptionHandlers workaround
View createApolloServer.js
/**
* @flow
* @prettier
*/
import { ApolloServer } from 'apollo-server-express'
import { typeof Server as HttpServer } from 'http'
import WebSocket from 'ws'
import { SubscriptionServer } from 'subscriptions-transport-ws'
import { formatApolloErrors } from 'apollo-server-errors'
@jedwards1211
jedwards1211 / useConnection.js
Last active Jun 3, 2020
useConnection (a React hook for infinite scrolling with Apollo, Relay-style Connections, and react-virtualized)
View useConnection.js
/**
* @flow
* @prettier
*/
import { type QueryRenderProps } from 'react-apollo'
import * as React from 'react'
import {
get,
takeRightWhile,
View OpenChat.js
/**
* @flow
* @prettier
*/
import * as React from 'react'
import { Query } from 'react-apollo'
import gql from 'graphql-tag'
import type { QueryRenderProps } from 'react-apollo'
import livechatPromise from '../util/livechat'
@jedwards1211
jedwards1211 / proxy.js
Created Sep 21, 2017
How to proxy and dump raw HTTP requests in node.js
View proxy.js
const {createServer} = require('http')
const proxy = require('http-proxy').createProxyServer()
var server = createServer(function (req, res) {
if (process.env.TARGET) proxy.web(req, res, { target: process.env.TARGET })
else res.end('OK\n')
})
server.on('connection', socket => socket.pipe(process.stdout))
const host = process.env.HOST || '0.0.0.0'
@jedwards1211
jedwards1211 / executeAsync.js
Last active Apr 18, 2017
webdriver parallel executeAsync bug
View executeAsync.js
import {expect} from 'chai'
import * as webdriverio from 'webdriverio'
import {run as runPhantomjs} from 'phantomjs-prebuilt'
describe('executeAsync', function () {
this.timeout(10000)
let phantomjs
let browser
@jedwards1211
jedwards1211 / Match.js
Last active Nov 3, 2017
Power <Match> for react-router v4
View Match.js
import React, { PropTypes } from 'react'
import MatchProvider from 'react-router/MatchProvider'
import matchPattern from 'react-router/matchPattern'
import { LocationSubscriber } from 'react-router/Broadcasts'
class RegisterMatch extends React.Component<void, RegisterMatchProps, void> {
static contextTypes = {
match: PropTypes.object,
serverRouter: PropTypes.object
}
@jedwards1211
jedwards1211 / pdf2png.sh
Last active Nov 8, 2015 — forked from yura/pdf2jpg.sh
script to PDF to JPG using pdftk and imagemagick
View pdf2png.sh
#!/bin/bash
# Script to convert PDF file to PNG images
#
# Dependencies:
# * ghostscript
for PDF in "$@"
do
echo "Processing $PDF..."
You can’t perform that action at this time.