Skip to content

Instantly share code, notes, and snippets.

View paulbjensen's full-sized avatar

Paul Jensen paulbjensen

View GitHub Profile
@paulbjensen
paulbjensen / app.coffee
Created December 30, 2010 11:14
How I do global variables with CoffeeScript
# app.coffee
fs = require 'fs'
express = require 'express'
tasty = require './tasty.js'
app = express.createServer()
md = require("node-markdown").Markdown
firstArticleData = ''
articleList = []
fs.readdir 'articles', (err, files) ->
@paulbjensen
paulbjensen / example.txt
Created October 1, 2022 13:39
Set slack status with AppleScript in Apple Shortcuts
-- Sets the status to Pomodoro
on run {input, parameters}
tell application "Slack 2"
activate
end tell
tell application "System Events"
-- Set status keyboard shortcut
keystroke "y" using {shift down, command down}
-- Would be great to do the following:
-- - Clear the previous status
@paulbjensen
paulbjensen / common.js
Created June 18, 2018 10:21
Step definitions, for an article on Medium
// Dependencies
const { Given, When, Then } = require('cucumber');
const {
visitHomepage,
assertUserHasPassword,
assertUserHasEmail,
userExists,
closeAccount,
pending,
clickOnItem,
@paulbjensen
paulbjensen / generateWebConfig.js
Created June 18, 2018 11:24
The generateWebConfig.js file, part of an article on Medium
// Writes a file to src/config.js exporting the baseUrl property
const config = require('../config');
const fs = require('fs');
const path = require('path');
const {
baseUrl,
googleAnalytics,
sentryDSN,
useDevTools,
env,
@paulbjensen
paulbjensen / selectors.js
Created June 18, 2018 10:55
selectors.js, part of an article on Medium
/*
NOTE - at some point these selectors will need to be scoped based on the page
that the user is accessing in the cucumber step
*/
const selectors = {
links: {
Signup: 'a[href="/signup"]',
Login: 'a[href="/login"]',
Logout: 'a.logout',
'I have forgotten my password': 'a[href="/forgot-password"]',
@paulbjensen
paulbjensen / pages.js
Created June 18, 2018 10:52
The pages.js support file, part of an article for Medium
const { Dashboard, Organisation } = require('api/models');
const pages = {
home: '/',
login: '/login',
signup: '/signup',
'forgot-password': '/forgot-password',
dashboard: '/dashboard',
account: '/account',
organisations: '/account/organisations',
@paulbjensen
paulbjensen / login_step_definition.js
Created June 18, 2018 10:42
The login step definition, part of an article on Medium
Given('I login', { timeout: 10000 }, async () => {
await visitHomepage();
await clickOnItem('Login');
await takenToPage('login');
await fillInFormField('identifier', email);
await fillInFormField('password', password);
await pressButton('Login');
return await shouldBeOnPage('dashboard');
});
@paulbjensen
paulbjensen / actions.js
Created June 18, 2018 10:24
The actions.js file, part of an article for Medium.
// Dependencies
const assert = require('assert');
const {
Dashboard,
DashboardUser,
User,
Organisation,
OrganisationUser,
ForgotPassword
} = require('api/models');
@paulbjensen
paulbjensen / hooks_v3.js
Created June 18, 2018 09:37
Version 3 of the hooks.js file, part of an article on Medium
/*eslint no-console: ["error", { allow: ["log"] }] */
// Dependencies
const { After, Before, AfterAll } = require('cucumber');
const {mongoose, redis } = require('api/db');
const {
User,
Dashboard,
DashboardUser,
Session,
ForgotPassword,
@paulbjensen
paulbjensen / hooks_v2.js
Created June 18, 2018 09:31
Version 2 of our hooks.js file, part of an article on Medium
/*eslint no-console: ["error", { allow: ["log"] }] */
// Dependencies
const { After, Before, AfterAll } = require('cucumber');
const scope = require('./support/scope');
Before(async () => {
});
After(async () => {
if (scope.browser && scope.context.currentPage) {