Skip to content

Instantly share code, notes, and snippets.

View kdzwinel's full-sized avatar

Konrad Dzwinel kdzwinel

View GitHub Profile
@paulirish
paulirish / devtools-protocol-send-command-and-monitor.md
Last active February 11, 2020 17:42 — forked from jasonLaster/inspector.js
how to issue commands and monitor the devtools protocol

Playing with the protocol

You can send arbitrary commands over the protocol fairly easily.

Main.sendOverProtocol('Emulation.setDeviceMetricsOverride', nexus5XMetrics());
Main.sendOverProtocol("Emulation.clearDeviceMetricsOverride");

// It returns a promise
@wwwillchen
wwwillchen / copy-tests-book.js
Created January 13, 2017 22:01
Copy Failed Layout Tests as a Bookmark
javascript:var $jscomp={scope:{}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(a){return $jscomp.SYMBOL_PREFIX+(a||"")+$jscomp.symbolCounter_++};$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIt
@jasonLaster
jasonLaster / inspector.js
Created March 28, 2015 00:08
monitoring the inspector backend class
var dispatch = InspectorBackendClass.Connection.prototype.dispatch;
InspectorBackendClass.Connection.prototype.dispatch = function() {
if (arguments && arguments.length > 0) {
var message = arguments[0];
var object = message ? JSON.parse(message) : {};
console.log.apply(console,['events', object]);
}
dispatch.apply(this, arguments);
}
@jodyheavener
jodyheavener / Import SVG.sketchplugin
Last active February 11, 2020 17:44
Import a desired SVG in to a Sketch canvas
// Import Ale's fantastic Sketch Sandbox
// https://github.com/bomberstudios/sketch-sandbox
#import 'sketch-sandbox.js'
// Are we on a page or an artboard?
var page = doc.currentPage();
var canvas = page.currentArtboard() ? page.currentArtboard() : page;
// Define the location of the file you want to import, using file:// protocol
var fileURL = NSURL.URLWithString("file:///Users/johndoe/Downloads/my_cat.svg");
@jaredwilli
jaredwilli / gist:c60e5f61a53af76b52ca
Last active February 11, 2020 17:45
Angular 2.0 questions answered by the Angular team
What is the release date for 2.0?
No exact release date yet. They don't want what happened with 1.2.They want to
make sure they get it done right for 2.0 so they are not setting a date yet.
What is the plan for having a migration path for 2.0? How much rewriting of 1.x
apps will need to be done to migrate to 2.0?
Mishko said that there will definitely be a migration plan for 2.0. They dont know
from urlparse import urlparse
from Crypto.Hash import MD2
import pandas as pd
import cookies as ck
import hackercodecs # noqa
import hashlib
import pyblake2
import urllib
import sha3
import mmh3
@kentbrew
kentbrew / setMultiHeaders.js
Created January 10, 2011 22:57
Setting multiple cookies (or whatever) per header with Node. Bonus: p3p line prevents IE from spazzing out.
response.writeHead(200, {
'p3p': ['policyref="http://foo.com/p3p.xml"', 'CP="OOO EEE OOH AH AHH"'],
'Set-Cookie': ['ting="tang; expires=0; path=/;"', 'wallawalla="bingbang; expires=123456789; path=/;"'],
'Content-Type': 'text/html'
});
@kris-ellery
kris-ellery / JS-error-tracking-with-GA.js
Last active November 18, 2021 19:00
Track JavaScript errors using Universal Analytics from Google.
/**
* Track JS error details in Universal Analytics
*/
function trackJavaScriptError(e) {
var errMsg = e.message;
var errSrc = e.filename + ': ' + e.lineno;
ga('send', 'event', 'JavaScript Error', errMsg, errSrc, { 'nonInteraction': 1 });
}
@badsyntax
badsyntax / find-unused-sass-variables.sh
Last active November 24, 2021 09:59 — forked from axelerator/Find unused variables in sass files
Find unused SCSS variables. Usage: `./find-unused-sass-variables.sh sassDir/`
#!/usr/bin/env bash
#
# Approach:
# 1. Find variable declaration in the form of "$my-var: anyvalue"
# 2. Loop through found variables and find occurrences of each variable in all sass files
# 3. Filter out vars that occurred only once
if [ -z "$1" ]; then
echo "Please specify a directory as the first argument."
exit 1
@paulirish
paulirish / readme.md
Last active June 17, 2022 06:46
resolving the proper location and line number through a console.log wrapper

console.log wrap resolving for your wrapped console logs

I've heard this before:

What I really get frustrated by is that I cannot wrap console.* and preserve line numbers

We enabled this in Chrome DevTools via blackboxing a bit ago.

If you blackbox the script file the contains the console log wrapper, the script location shown in the console will be corrected to the original source file and line number. Click, and the full source is looking longingly into your eyes.