Skip to content

Instantly share code, notes, and snippets.

View cartogram's full-sized avatar

Matt Seccafien cartogram

View GitHub Profile
@cartogram
cartogram / guide.md
Last active December 31, 2023 01:08
Mock.Shop Hydrogen Extension

Use Mock.shop in Hydrogen

There are many reasons why you would want to test your storefront against another storefront's data. For example, you may want to test your feature against a different set of product data.

Extend the Storefront API

const storefrontClient = createStorefrontClient({...})

/**
@cartogram
cartogram / action.ts
Last active March 13, 2023 16:12
Hydrogen Customer Context
export const action: ActionFunction = async ({request, context}) => {
const formData = await request.formData()
const {customer} = context
try {
await customer.authenticate({
email,
password,
})
@cartogram
cartogram / node-client.ts
Last active October 4, 2019 06:12
Sockets: Node <--> Ruby
import net, {Socket} from 'net';
export function createServer() {
const client: Socket = new net.Socket();
client.setEncoding('utf8');
client.on('connect', function() {
console.log('Client: connection established with server');
@cartogram
cartogram / ruby.rb
Created October 4, 2019 05:46
Sockets: Node <--> Ruby
require 'socket'
class Server
def initialize()
@server_socket = TCPServer.new("127.0.0.1", 3000)
run
end
def run
loop do
@cartogram
cartogram / mock-poc.md
Created May 3, 2019 04:47
Notes on webgen

MockFS

Workspace at this point contains essentially EVERYTHING we do. All filesystem shit etc. How it gets itself set up is its own deal. For example, workspace.usesRails can be injected into the test but can be something we just put it into that position. And if we want to assert that some read or write was called, we would replace those with spys.

Smoething about the flush part. SOmthing with files and stuff.

Right i twas that it would start with some array but it would have that internally to start. So if you run this on an exisiting project, it will read files and keep them in its internal memory, like a scan project thing.

class Workspace {

const originalDefer = useLazyRef(() => defer);
if (originalDeferPolicy !== defer) {
throw new Error('something helpful');
}
if (originalDefer === DeferTiming.inViewport) {
React.useEffect(
() => {
if (
result.status === Status.Initial &&
@cartogram
cartogram / after-importHelpers
Last active December 4, 2018 20:03
Quilt Sizes
packages/admin-graphql-api-utilities/dist/index.d.ts, packages/admin-graphql-api-utilities/dist/index.js
Package size: 592 B
Size limit: 600 B
packages/dates/dist/apply-time-zone-offset.js, packages/dates/dist/apply-time-zone-offset.d.ts, packages/dates/dist/deprecated-timezones.d.ts, packages/dates/dist/deprecated-timezones.js, packages/dates/dist/get-date-time-parts.js, packages/dates/dist/get-date-time-parts.d.ts, packages/dates/dist/get-time-zone-offset.d.ts, packages/dates/dist/get-time-zone-offset.js, packages/dates/dist/index.d.ts, packages/dates/dist/index.js, packages/dates/dist/is-same-day.d.ts, packages/dates/dist/is-same-day.js, packages/dates/dist/is-same-month.d.ts, packages/dates/dist/is-same-month.js, packages/dates/dist/is-same-year.d.ts, packages/dates/dist/is-same-year.js, packages/dates/dist/is-today.d.ts, packages/dates/dist/is-today.js, packages/dates/dist/is-tomorrow.d.ts, packages/dates/dist/is-tomorrow.js, packages/dates/dist/is-yesterday.js, packages/dates/dist/is-yesterda
@cartogram
cartogram / createRouter.ts
Last active November 26, 2018 18:15
Shopify React Router 4 Changes
// The API for creating a mock router with `CreateRouter` has been simplified.
// Before
const wrapper = await mountWithAppContext(<SomeComponent />, {
router: createRouter({
location: createLocation({
state: {someStateKey: stateVariables},
pathname: 'some/path'
params: {key: 'value'},
search: '?query',
const config = {
storeName: 'fededucation',
accessToken: 'afcc240c1a1939177dd7fc5c336ff6c8',
};
// This works
const ProductsQueryRaw = `{
shop {
name
/**
* Button/index.js
*/
import React, { Children } from 'react';
function Button(props) {
const {
href,
onClick,