Skip to content

Instantly share code, notes, and snippets.

View villesau's full-sized avatar

Ville Saukkonen villesau

View GitHub Profile
@villesau
villesau / find-elem-with-breakout-width-2.js
Created July 27, 2022 14:20 — forked from joshwcomeau/find-elem-with-breakout-width.js
Paste this in your browser console to search for HTML elements which extend past the window's width and create a horizontal scrollbar.
let widestElement = document.body;
let widestElementDepth = 0;
function checkElemWidth(elem, depth) {
const currentWidest = widestElement.getBoundingClientRect();
const boundingRect = elem.getBoundingClientRect();
const currentRight = currentWidest.right;
const right = boundingRect.right;
if (right >= currentRight && depth > widestElementDepth) {
widestElement = elem;
@villesau
villesau / has-folder-changed.sh
Created November 8, 2021 20:40
Has folder changed between merges
git diff --quiet HEAD $(git rev-list --max-count=1 --merges --skip=1 HEAD) -- $FOLDER
/*
A collection of tests where Flow and TypeScript might have different behavior
Some tests are borrowed from https://github.com/vkurchatkin/typescript-vs-flow
Some tests now have the same behavior as the new versions of Flow/TS have fixed the bugs and improved type safety
*/
/* 1. Accessing unknown properties on objects */
/**
* TDD language that can used in tests for more descriptive test writing and smaller scopes.
* Note that we don't actually run tests, these are simply present to mimic the TDD verbs we know and love.
*
* Usage:
*
* describe('#someFunction', () => {
* it('should do something', () => {
* // test...
* })
@villesau
villesau / request_v2.83.x.js
Created February 28, 2018 21:07
libdef draft for request
declare module "request" {
import type { IncomingMessage } from 'http';
declare type Defaults = $Shape<{|
proxy: string
|}>;
declare class Request extends stream$Duplex {
auth(
username: ?string,
password: ?string,
@villesau
villesau / password replacing regex
Created July 8, 2015 07:55
want to replace your password field from your json string?
("password":")(?:\\"|[^"])*"