Skip to content

Instantly share code, notes, and snippets.

Konrad Dzwinel kdzwinel

Block or report user

Report or block kdzwinel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kdzwinel
kdzwinel / filter-out-ads.js
Last active Mar 22, 2018
TrackJS custom onError callback that tries to filter out noise from ads
View filter-out-ads.js
// ES5 for compat
window._trackJs.onError = function(error) {
try {
var fileURL = new URL(error.file);
if (fileURL) {
// safelist includes current domain + some third-parties we want to track
var safe = domainSafelist.some(function (domain) {
return fileURL.host.endsWith(domain);
});
@kdzwinel
kdzwinel / lhjson.js
Created Jan 25, 2018
__LIGHTHOUSE_JSON__ analysis script
View lhjson.js
(function() {
function strSize(obj) {
const string = JSON.stringify(obj);
return string ? string.length : 0;
}
const lhj = __LIGHTHOUSE_JSON__;
const fullSize = strSize(lhj);
const maxLevels = 5;
@kdzwinel
kdzwinel / get-selector-simple.js
Created Dec 8, 2017
Simple alternative to the axe-core getSelector
View get-selector-simple.js
const commonNodes = [
'div', 'span', 'p',
'b', 'i', 'u', 'strong', 'em',
'h2', 'h3',
];
/**
* @param {Array<string>} attributes
* @returns {Map<string, string>}
*/
@kdzwinel
kdzwinel / ps4devtools.js
Created Oct 8, 2017
Gamepad - Chrome DevTools integration
View ps4devtools.js
(function(){
let gamepad = null;
let loopInterval = null;
window.addEventListener("gamepadconnected", connectHandler);
window.addEventListener("gamepaddisconnected", disconnectHandler);
function connectHandler(e) {
if (!gamepad) {
@kdzwinel
kdzwinel / extension.js
Last active Oct 25, 2017
Quick and dirty implementation of runtime type profiling in Visual Studio Code
View extension.js
const vscode = require('vscode');
const path = require('path');
// puppeteer is great because it's easy to use, but it comes with 30MB headless Chrome that
// we can't use as it doesn't have `Profiler.startTypeProfile` yet. We have to point to a
// locally installed Chrome Canary instead. It's fine for a POC, but puppeteer isn't probably
// a good fit in a long run.
const puppeteer = require('puppeteer');
const PATH_TO_CANARY = '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary';
@kdzwinel
kdzwinel / raf_throttler.js
Created Jul 7, 2017
Waiting for IntersectionObserver to get a better support…
View raf_throttler.js
function rafThrottler(callback) {
let rafId = null;
const flush = () => {
callback();
rafId = null;
};
return () => {
if (rafId) {
return;
@kdzwinel
kdzwinel / scroll_to.js
Created May 2, 2017
Scroll to element or scroll by value
View scroll_to.js
let rafId;
function scrollToElement(el, offsetTop = 0) {
scrollByValue(el.getBoundingClientRect().top - offsetTop);
}
function scrollByValue(offsetTop = 0) {
if (offsetTop !== 0) {
if (rafId) {
cancelAnimationFrame(rafId);
@kdzwinel
kdzwinel / jsk.c
Created Jan 19, 2017
JSK -JPEG Scan Killer
View jsk.c
/*
* jsk.c
*
* Copyright (C) 2013, Frederic Kayser.
*
*/
#include <stdio.h>
#include <stddef.h>
@kdzwinel
kdzwinel / npm-yo.har
Created Oct 14, 2016
`yarn add yo` vs `npm i yo` HARs
View npm-yo.har
This file has been truncated, but you can view the full file.
{
"log": {
"version": "1.2",
"creator": {
"name": "WebInspector",
"version": "537.36"
},
"pages": [],
"entries": [
@kdzwinel
kdzwinel / concentrate.js
Last active Sep 30, 2017
DevTools snippet that lets you focus on a single element during developement
View concentrate.js
(function() {
function hideEvertyhingAround($el) {
const $parent = $el.parentElement;
$parent.style.transition = 'background-color 150ms ease-in';
$parent.style.backgroundColor = 'white';
$parent.childNodes.forEach($child => {
if($child !== $el && $child.style) {
You can’t perform that action at this time.