Skip to content

Instantly share code, notes, and snippets.

Avatar

Leonhard Melzer leomelzer

View GitHub Profile
@leomelzer
leomelzer / index.ts
Created Feb 2, 2021
Set SVG dimensions in GraphCMS
View index.ts
import fetch from "node-fetch";
import imageSize from "image-size";
import { GraphQLClient, gql } from "graphql-request";
const ENDPOINT =
"https://api-eu-central-1.graphcms.com/v2/myProject/master";
const TOKEN =
"myTokenWithMutationPrivileges";
type Asset = Record<"id" | "handle" | "url", string> &
@leomelzer
leomelzer / input.story.js
Created Nov 7, 2019
$ jscodeshift -t renameDefaultStory.js **/*.story.js
View input.story.js
export const defaultStory = () => <StatusDot />;
@leomelzer
leomelzer / input.story.js
Last active Nov 7, 2019
$ jscodeshift -t removeStoryConfig.js **/*.story.js
View input.story.js
export const usePlaceholder = () => (
<TextField placeholder="I am a placeholder" />
);
usePlaceholder.story = {
name: 'use placeholder'
};
View now-options.md
Option Description
version We'll use the (current) version 2 of the Now platform. Version 1 will be deprecated in the future but is still fully supported. Since the platform versions are based on different concepts, the specific options are different, too.
name The name of the application, usually the same as in package.json. This will be used as a label in the Now UI to identify the application.
alias This is the default argument for the now alias command. The alias will point to the randomly generated subdomain where Now created your immutable deployment. You must add the domain to Now in order to use this feature. You may add multiple aliases and also use subdomains here (e.g. foo.example.org if you already added the domain example.org to Now).
builds A Now application may be deployed using any of the available builders such as for Node.js, Go, Python and so on. We'll use the `static-buil
@leomelzer
leomelzer / main.workflow
Created Jan 8, 2019
The textual representation of the workflow, `main.workflow`.
View main.workflow
workflow "Deploy to Now" {
on = "push"
resolves = [
"Alias",
"Filter out master branch",
]
}
action "Deploy" {
uses = "actions/zeit-now@master"
@leomelzer
leomelzer / package.json
Created Jan 8, 2019
Simplified package.json with the added now-build script.
View package.json
{
"name": "jetztein",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"now-build": "npm run build && mv build dist"
}
}
@leomelzer
leomelzer / now.json
Created Jan 8, 2019
now.json file with routing rules for a Create-React-App.
View now.json
{
"version": 2,
"name": "jetztein",
"alias": "jetztein.de",
"builds": [{ "src": "package.json", "use": "@now/static-build" }],
"regions": ["bru"],
"routes": [
{ "src": "^/static/(.*)", "dest": "/static/$1" },
{ "src": "^/favicon.ico", "dest": "/favicon.ico" },
{ "src": "^/asset-manifest.json", "dest": "/asset-manifest.json" },
@leomelzer
leomelzer / Dockerfile
Last active Feb 22, 2021
Install private NPM dependencies using git+ssh on Now. Based on https://zeit.co/blog/build-env to work around missing support for git+ssh dependencies in now@2 (https://github.com/zeit/now-builders/issues/49)
View Dockerfile
# This is a multi-stage build to not spill the contents of the deploy_key
FROM mhart/alpine-node:10 as base
# We need git and openssh to resolve `git+ssh` links in package.json
RUN apk update \
&& apk add git openssh
WORKDIR /usr/src
COPY package*.json ./
View express.js
var t = require('../test-lib/test.js');
var assert = require('assert');
var _ = require('@sailshq/lodash');
var apos;
describe('Express', function() {
this.timeout(t.timeout);
it('express should exist on the apos object', function(done) {
@leomelzer
leomelzer / index.js
Created Jun 19, 2018
metatag-diff: Compare (diff) metatags of prod and stage host version given an article slug.
View index.js
const fetch = require("node-fetch");
const cheerio = require("cheerio");
const diff = require("diff");
const colors = require("colors");
const inputSlug = process.argv[2];
const notImplemented = [
"[rel=amphtml]",
"[property='og:image']",