Skip to content

Instantly share code, notes, and snippets.

Henric Trotzig trotzig

Block or report user

Report or block trotzig

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@trotzig
trotzig / happo-ci-jenkins.sh
Created Aug 15, 2019
An example of a Happo CI script for Jenkins
View happo-ci-jenkins.sh
#!/bin/bash
# Make the whole script fail on errors
set -euo pipefail
PREVIOUS_SHA=$(git merge-base origin/master "${CIRCLE_SHA1}")
export PREVIOUS_SHA
export CURRENT_SHA="$(git rev-parse ${1-HEAD})"
export CHANGE_URL="$GERRIT_CHANGE_URL"
View happo-circleci-webinar.md

Install happo and plugin:

yarn add --dev happo.io happo-plugin-storybook

.happo.js config

const { RemoteBrowserTarget } = require('happo.io');
const happoPluginStorybook = require('happo-plugin-storybook');
@trotzig
trotzig / Instructions-for-beta-testing-happo-plugin-storybook.md
Last active Jan 21, 2019
Instructions for using happo-plugin-storybook
View Instructions-for-beta-testing-happo-plugin-storybook.md

First, install the latest happo packages:

yarn add --dev happo-plugin-storybook@latest happo.io@latest

Add the plugin to .happo.js:

const happoPluginStorybook = require('happo-plugin-storybook');
@trotzig
trotzig / .happo.js
Created Jan 8, 2019
Example of using happo-plugin-scrape with a wrapper element
View .happo.js
const path = require('path');
const { RemoteBrowserTarget } = require('happo.io');
const happoScrapePlugin = require('happo-plugin-scrape');
function commonWrapper(html) {
return `
<div class="application-wrapper">
<div style="width:100%" class="od-homepage">${html}</div>
</div>
`;
View validateS3Account.js
const AWS = require('aws-sdk');
const {
S3_REGION: region,
S3_BUCKET_NAME: Bucket,
S3_ACCESS_KEY_ID: accessKeyId,
S3_SECRET_ACCESS_KEY: secretAccessKey,
} = process.env;
AWS.config.update({
region,
View deploy-to-now.sh
#!/bin/bash
browser=$1
if [ -z "$browser" ]; then
echo "Usage: ./deploy.sh <browser>"
exit 1
fi
set -euo pipefail
# Copy the right files
View postStatus.js
const octokit = require('@octokit/rest');
const jsonwebtoken = require('jsonwebtoken');
const PEM = `-----BEGIN RSA PRIVATE KEY-----
<REDACTED>
-----END RSA PRIVATE KEY-----`;
function generateJwtToken() {
// Sign with RSA SHA256
return jsonwebtoken.sign(
@trotzig
trotzig / makeRequest.js
Created Jan 26, 2018
JWT creation for happo.io
View makeRequest.js
import request from 'request-promise-native';
import jwt from 'jsonwebtoken';
export default function makeRequest(requestAttributes, { apiKey, apiSecret }) {
const signed = jwt.sign({ key: apiKey }, apiSecret, { header: { kid: apiKey } });
return request(
Object.assign({
auth: {
bearer: signed,
},
View happo-example.jsx
import Button from './';
export const primary = () =>
<Button primary>Submit</Button>;
export const secondary = () =>
<Button secondary>Cancel</Button>;
export const disabled = () =>
<Button disabled>Send</Button>;
You can’t perform that action at this time.