Skip to content

Instantly share code, notes, and snippets.

View incognitoPage.js
function createIncognitoPage() {
const browserSession = await state.browser.targets()
.find(t => t.type() === 'browser')
.createCDPSession();
const {browserContextId} = await browserSession.send('Target.createBrowserContext');
const {targetId} = await browserSession.send('Target.createTarget', {url: 'about:blank', browserContextId});
// Clean up the context when the page is destroyed
state.browser.on('targetdestroyed', async function disposeBrowserContext(target) {
View incognitoPage.spec.js
describe('supports using browser contexts with CDP sessions', function() {
beforeEach(async state => {
const browserSession = await state.browser.targets()
.find(t => t.type() === 'browser')
.createCDPSession();
const {browserContextId} = await browserSession.send('Target.createBrowserContext');
const {targetId} = await browserSession.send('Target.createTarget', {url: 'about:blank', browserContextId});
// Clean up the context when the page is destroyed
@haroldhues
haroldhues / bashrc_snippet.sh
Created Sep 22, 2016
Seeq Worktree Review Alias
View bashrc_snippet.sh
# Checkout a branch in a worktree and build it. Usefull for reviewing a branch.
# After it the command completes the directory will be changed to the new
# branch and it should be ready to be run.
#
# Assumes that the branch exists on `origin` and a branch has not been checked
# out yet.
#
# NOTE: Get a cup of coffee while running, it will take a while...
#
# Usage: review feature/me/my-awesome-branch-name
@haroldhues
haroldhues / CopyRightNotice.cs
Last active Apr 18, 2016
Add this code to a unit test project, install the roslyn packages, and change variables at the top!
View CopyRightNotice.cs
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
//Install-Package Microsoft.CodeAnalysis
@haroldhues
haroldhues / TaskAsService.cs
Created Aug 16, 2015
Wraps a TPL Task to provide Start, Stop, IsRunning interface
View TaskAsService.cs
using System;
using System.Threading;
using System.Threading.Tasks;
using TPLTask = System.Threading.Tasks.Task;
namespace Contracts
{
public class TaskAsService
{
private CancellationTokenSource _cancel = new CancellationTokenSource();
@haroldhues
haroldhues / DesignData.tt
Created Jul 19, 2015
T4 Template to Convert JSON File to (WPF) XAML Data Representation for use with Visual Studio Designer
View DesignData.tt
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="$(ProjectDir)bin\Debug\Newtonsoft.Json.dll" #>
<#@ assembly name="$(ProjectDir)bin\Debug\Contracts.dll" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Reflection" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Collections" #>
@haroldhues
haroldhues / keyboardbacklight.ahk
Created Apr 5, 2015
Reverse State of ScrollLock LED
View keyboardbacklight.ahk
#SingleInstance force
; I have a backlit keyboard that used the ScrollLock led to determine when the
; lights are on, this script basically reverses the state so that ScrollLock is
; off when the light is on.
~NumLock::
~CapsLock::
~ScrollLock::
Sleep, 10 ; improve reliability of setting LED state sometimes
If (GetKeyState("ScrollLock", "T"))
KeyboardLED(1,"off")
@haroldhues
haroldhues / vim-vs.ahk
Last active Aug 29, 2015
AutoHotkey Definitions for 'vim' like Bindings for Visual Studio
View vim-vs.ahk
; By Cody Ray Hoeft
;
; These key bindings are for Visual Studio (VS in comments), but the script
; could easily be changed to do the same thing to any windows program
;
; The Goal of this script is to provide keyboard bindings similar to vim's
; bindings. Note that many are not anything like vims, when I say that they
; are similar I mean that you can toggle between to states and you can
; navigate using hjkl
;