Skip to content

Instantly share code, notes, and snippets.

View Robdel12's full-sized avatar
🏁
Making a PitStop

Robert DeLuca Robdel12

🏁
Making a PitStop
View GitHub Profile
@Robdel12
Robdel12 / toggle-plug.js
Last active February 25, 2022 08:43
Toggle Meross Plug from Node
"use strict";
// TODO: I know, I know, don't use request...
const request = require("request");
// Wrap request with a promise to make it awaitable
function doRequest(options) {
return new Promise(function(resolve, reject) {
request(options, function(error, res, body) {
if (!error && res.statusCode == 200) {
events:
enabled: true
subscriptions:
- command: node ~/scripts/turn-off-printer.js
event: PrintDone
type: system
system:
actions:
- name: Turn off printer
action: turnoff
// snagged from MDN
// The goal is to take all the CSS created in the CSS Object Model (CSSOM)
// and inject it into the DOM so Percy can render it safely in our browsers
let cssOmStyles = [].slice.call(document.styleSheets).reduce((prev: String, styleSheet: CSSStyleSheet) => {
// Make sure it has a rulesheet, does NOT have a href (no external stylesheets), and isn't already in the DOM.
let hasHref = styleSheet.href;
let hasStyleInDom = styleSheet.ownerNode.innerText.length > 0;
if (styleSheet.cssRules && !hasHref && !hasStyleInDom) {
return (
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Emberx-select demo',
xSelectValue: 'bob',
actions: {
setXSelect(value) {
this.set('xSelectValue', value);
}
}
@Robdel12
Robdel12 / lambda.js
Created May 2, 2019 14:38 — forked from luketheobscure/lambda.js
Percy Bitbucket AWS Lambda
const https = require('https');
const AUTHORIZATION = ''; // base 64 of user:password
const BITBUCKET_USER = ''; // either the user or the org that owns the repo
const PERCY_USER = ''; // the name of your percy user or org
exports.handler = (event, context, callback) => {
/**
We need to post to a URL like this:
https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<hash>/statuses/build
const PercyScript = require('@percy/script');
const fs = require('fs');
const path = require('path');
const directories = [
path.resolve(__dirname, '../src/components/elements'),
path.resolve(__dirname, '../src/components/patterns'),
path.resolve(__dirname, '../src/components/templates'),
];
const PercyScript = require("@percy/script");
const fs = require("fs");
const path = require("path");
const directories = [
{
type: "Element",
path: path.resolve(__dirname, "src/components/elements")
},
{
pipelines:
default:
- step:
name: Visual test
image: circleci/node:8-browsers
script:
- node -v
- npm -v
- npx percy exec -- node ./snapshots.js
{
"devDependecies": {
},
"percy": {
"version": 1,
"agent": {
"request-headers": {
"Authentication": "Basic c3RnOnN0ZzEyMw=="
}
@Robdel12
Robdel12 / cypress-interactor.js
Created July 15, 2019 14:33
Interactor.js + Cypress
beforeEach(function() {
// Tell Interactor where the applications DOM is
// since Cypress runs the test specs in an isolated iframe (away from the app DOM)
cy.window().then(remoteWindow => {
Object.defineProperty(Interactor.prototype, "$dom", {
get() {
return remoteWindow;
}
});
});