Skip to content

Instantly share code, notes, and snippets.

@joey-g
joey-g / headless-wd-example.es6
Last active April 26, 2024 23:17
Headless Chrome - WebDriver Example
// https://developers.google.com/web/updates/2017/04/headless-chrome
const fs = require('fs');
const {Builder, By, Capabilities, Key, until} = require('selenium-webdriver');
const chromedriver = require('chromedriver');
const chromeCapabilities = Capabilities.chrome();
chromeCapabilities.set('chromeOptions', {args: ['--headless']});
async function test() {
// Note: On macOS, you'll likely see a new Chrome process flash on your 'Dock'
// when this new driver object is built. As it's launched headlessly, it's
@svkrclg
svkrclg / custom_binary_test.js
Created September 29, 2020 14:19
Run specific chrome binary
const fs = require('fs');
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
(async () => {
const chrome = await chromeLauncher.launch({chromePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"}); //Specify chrome binary path to run lighthouse.
const options = {logLevel: 'info', output: 'html', onlyCategories: ['performance'], port: chrome.port};
const runnerResult = await lighthouse('https://example.com', options);
// `.report` is the HTML report as a string
@VerteDinde
VerteDinde / index.html
Created September 28, 2023 14:19
Message Port Chrome Repro
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
@adrice727
adrice727 / karma.conf.js
Last active April 26, 2024 23:17
karma-webpack => require is not defined
const path = require('path');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config');
module.exports = function (config) {
let sauceLaunchers = {
ie: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: process.env.BVER === '10' ? 'Windows 8' : 'Windows 8.1',
@iros
iros / application.js
Created November 12, 2011 17:34
BackboneTraining-require.js
// Define whatever global space vars you might need.
var mbta = {
// application configuration parameters
app : {
server : "http://backbonetraining.bocoup.com:8000"
},
// application data
data : {
// station collection
lines : null
@ckzgraphics
ckzgraphics / ChromeOptions_ChromeExtension.js
Last active April 26, 2024 23:16
Add Chrome extension to the Chrome browser in NodeJS + Selenium
var webdriver = require('selenium-webdriver');
var chrome = require("selenium-webdriver/chrome");
var fs = require('fs');
let file_path = '/Users/test/Downloads/Page Ruler.crx';
let buff = new Buffer.from(fs.readFileSync(file_path));
let base64data = buff.toString('base64');
var capabilities = {
@hamik112
hamik112 / dominus.js
Last active April 26, 2024 23:16
Require.js
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.dominus=t()}}(function(){return function t(e,n,r){function o(u,c){if(!n[u]){if(!e[u]){var f="function"==typeof require&&require;if(!c&&f)return f(u,!0);if(i)return i(u,!0);var a=new Error("Cannot find module '"+u+"'");throw a.code="MODULE_NOT_FOUND",a}var s=n[u]={exports:{}};e[u][0].call(s.exports,function(t){var n=e[u][1][t];return o(n?n:t)},s,s.exports,t,e,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(t,e,n){(function(n){"use strict";function r(t,e,n,r){return t.addEventListener(e,n,r)}function o(t,e,n){return t.attachEvent("on"+e,a(t,e,n))}function i(t,e,n,r){return t.removeEventListener(e,n,r)}function u(t,e,n){var r=s(t,e,n);return r?t.detachEvent("on"+e,r):void 0}functi
@N0taN3rd
N0taN3rd / chromeCrawling.js
Created May 5, 2017 16:36
use chrome to crawl
const CDP = require('chrome-remote-interface')
const Promise = require('bluebird')
const util = require('util')
const path = require('path')
const fs = require('fs-extra')
const filenameify = require('filenamify-url')
const JsDetector = require('./lib/jsDetector')
const detectLib = require('./lib/detectlibs')
const {apps, categories} = fs.readJsonSync('./lib/apps.json')
@lyoshenka
lyoshenka / search-git-history.md
Last active April 26, 2024 23:16
Search Git commit history for a string and see the diffs

Searching Git commit history

This should be one of the core features of Git, but for some reason it's impossible to figure out how to search for a string in your commit history and see the diffs that that string is in. Here's the best I've come up with:

To find which commits and which files a string was added or removed in:

git log -S'search string' --oneline --name-status

To see the diff of that

@FedericoElles
FedericoElles / fastclick.cdn.ondemand.js
Created March 23, 2016 08:28
Android: Is fastclick.js needed or required?
//Test URL:
// http://ftlabs.github.io/fastclick/examples/layer.html
(function () {
function isNeeded() {
var metaViewport;
var chromeVersion;
// Devices that don't support touch don't need FastClick