Skip to content

Instantly share code, notes, and snippets.

View niieani's full-sized avatar

Bazyli Brzóska niieani

View GitHub Profile
@niieani
niieani / no_automount.bash
Created August 18, 2022 05:16
Prevent an external drive from auto mounting on macOS
#!/usr/bin/env bash
# Taken from: https://akrabat.com/prevent-an-external-drive-from-auto-mounting-on-macos/
# Usage: ./no_automount My\ Disk
NAME=$1
if [ -z "$NAME" ] ; then
echo "Usage: no_automount {Disk Name}"
exit 1
@niieani
niieani / laika-example.ts
Created November 11, 2021 00:25
An example Cypress test using Laika's Subscription mocking
import type {Laika, InterceptApi} from '@zendesk/laika'
describe('My suite', () => {
let laika: Laika
before(() => {
cy.visit('/')
cy.window()
.its('laika')
.then((instance) => {
@niieani
niieani / laika-example.ts
Created November 10, 2021 22:48
Loading Laika in production code conditionally
import { createLazyLoadableLaikaLink } from '@zendesk/laika'
const conditionalLinks = window.Cypress
? [createLazyLoadableLaikaLink({ clientName: 'my-graph' })
: []
const apolloClient = new ApolloClient({
link: ApolloLink.from([
...conditionalLinks,
new HttpLink({ uri: 'https://api.example.com/graphql' }),
@niieani
niieani / laika-example.ts
Last active November 11, 2021 00:37
Laika intercepts are similar to mock functions
it('mocks the rocket launches once', () => {
// the `laika` variable below can come either from the global instance, when running in the browser
// or in case of unit tests, it might be a link we've set up in a `beforeAll` of this test suite
const interceptor = laika.intercept({ operationName: 'ListMissions' })
interceptor.mockResultOnce({
result: {
data: {
launchesPast: [
{ mission_name: 'Sputnik 2', launch_site: { site_name_long: 'Baikonur 1/5' } },
@niieani
niieani / lighthouse+8.5.1.patch
Last active October 12, 2021 07:49
Add networkIdleIgnoredUrlPatterns to Lighthouse
diff --git a/lighthouse-core/config/constants.js b/lighthouse-core/config/constants.js
index 264402bb026484a293a9efac60405c52eb8f525b..4aa5098162b70d83ed4ba6c630894ebaf27908a9 100644
--- a/lighthouse-core/config/constants.js
+++ b/lighthouse-core/config/constants.js
@@ -114,6 +114,7 @@ const defaultSettings = {
budgets: null,
locale: 'en-US', // actual default determined by Config using lib/i18n
blockedUrlPatterns: null,
+ networkIdleIgnoredUrlPatterns: null,
additionalTraceCategories: null,
@niieani
niieani / google-photos.user.css
Created July 9, 2019 20:11
Remove top gradient in Google Photos
/* ==UserStyle==
@name Remove top gradient in Google Photos - 09/07/2019, 22:08:26
@namespace github.com/niieani
@version 1.0.0
@description Removes the annoying top gradient in the Google Photos views: full screen photo, album
@author Bazyli Brzóska
==/UserStyle== */
@-moz-document domain("photos.google.com") {
.KYCEmd {
background-image: none;
@niieani
niieani / has-property.ts
Created April 21, 2018 06:08
TypeScript hacks
type HasProperty<X, P> = (X[keyof X & P] extends P ? true : false) extends false ? true : false
type example = HasProperty<{type:1}, 'type'>
@niieani
niieani / example.sh
Created March 8, 2018 18:19
Bash Module System
#!/usr/bin/env bash
SCRIPT_DIR=${BASH_SOURCE[0]%/*}
# load our module system:
source "${SCRIPT_DIR}/module.sh"
# below command imports module ./greeter.sh and run its 'greet' function with the following arguments:
module greeter greet tterranigma
module greeter greet niieani
@niieani
niieani / jestAsyncSuite.js
Created March 4, 2018 18:51
jest async suite
const { default: reporter } = require.requireActual(
"jest-jasmine2/build/reporter"
);
function runSuite(suite, parentSuite) {
const topSuite = jasmine.getEnv().topSuite();
const { children, id, result } = topSuite;
// setting this suite to disabled will not cause jest to
// clearResourcesForRunnable for this suite's ID
suite.disabled = true;
@niieani
niieani / WrappedImportDependencyTemplate.js
Created January 24, 2018 21:37
WrappedImportDependencyTemplate - wrap the closest asynchronous import() and add logic to it
// @flow
// let's ensure we require the right instance of webpack (when package is linked):
const require = module.parent && module.parent.parent && module.parent.parent.require
? module.parent.parent.require.bind(module.parent.parent)
: module.require
export type DebuggerType = (context : string, meta : Object) => void
const ImportDependency = require('webpack/lib/dependencies/ImportDependency')