Skip to content

Instantly share code, notes, and snippets.

View jedwards1211's full-sized avatar

Andy Edwards jedwards1211

View GitHub Profile
@jedwards1211
jedwards1211 / pdf2png.sh
Last active November 8, 2015 20:21 — forked from yura/pdf2jpg.sh
script to PDF to JPG using pdftk and imagemagick
#!/bin/bash
# Script to convert PDF file to PNG images
#
# Dependencies:
# * ghostscript
for PDF in "$@"
do
echo "Processing $PDF..."
@jedwards1211
jedwards1211 / Match.js
Last active November 3, 2017 14:01
Power <Match> for react-router v4
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 / executeAsync.js
Last active April 18, 2017 22:00
webdriver parallel executeAsync bug
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 / proxy.js
Created September 21, 2017 22:10
How to proxy and dump raw HTTP requests in node.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'
/**
* @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 / useConnection.js
Last active June 3, 2020 12:00
useConnection (a React hook for infinite scrolling with Apollo, Relay-style Connections, and react-virtualized)
/**
* @flow
* @prettier
*/
import { type QueryRenderProps } from 'react-apollo'
import * as React from 'react'
import {
get,
takeRightWhile,
@jedwards1211
jedwards1211 / createApolloServer.js
Created January 15, 2020 17:04
installSubscriptionHandlers workaround
/**
* @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 / nitropack+2.5.2.patch
Created August 15, 2023 00:36
Patch for using Nitro 2.5.2 with Cloudflare Pages
diff --git a/node_modules/nitropack/dist/shared/nitro.7a525996.mjs b/node_modules/nitropack/dist/shared/nitro.7a525996.mjs
index 90c7e4a..859bee1 100644
--- a/node_modules/nitropack/dist/shared/nitro.7a525996.mjs
+++ b/node_modules/nitropack/dist/shared/nitro.7a525996.mjs
@@ -1768,6 +1768,7 @@ export const plugins = [
conditions: [
"default",
nitro.options.dev ? "development" : "production",
+ "workerd",
"module",