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 / index.md
Last active Dec 29, 2015
What can be built with JS/HTML/CSS?
View index.md

#What can be built with JS/HTML/CSS?

Any application that can be written in JavaScript will eventually be written in JavaScript.

Jeff Atwood, July 17, 2007

Desktop app

@kdzwinel
kdzwinel / trilateration.js
Created Jan 3, 2014
Simple trilateration algorithm implementation in JavaScript.
View trilateration.js
function getTrilateration(position1, position2, position3) {
var xa = position1.x;
var ya = position1.y;
var xb = position2.x;
var yb = position2.y;
var xc = position3.x;
var yc = position3.y;
var ra = position1.distance;
var rb = position2.distance;
var rc = position3.distance;
@kdzwinel
kdzwinel / LICENSE.txt
Last active Aug 29, 2015
Custom Elements finder < 140 bytes (119 bytes)
View LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@kdzwinel
kdzwinel / reloadCSS.js
Last active Aug 20, 2017
Reload CSS files without reloading the page
View reloadCSS.js
function reloadCSS() {
const links = document.getElementsByTagName('link');
Array.from(links)
.filter(link => link.rel.toLowerCase() === 'stylesheet' && link.href)
.forEach(link => {
const url = new URL(link.href, location.href);
url.searchParams.set('forceReload', Date.now());
link.href = url.href;
});
@kdzwinel
kdzwinel / mkgif.sh
Last active Nov 9, 2017
Making gifs from mov files on OS X.
View mkgif.sh
#!/bin/sh
palette="./palette.png"
# speed - setpts=0.15*PTS,
# crop - ffmpeg -i in.mov -filter:v "crop=480:600:320:80" out.mov
filters="fps=25,scale=640:-1:flags=lanczos"
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
@kdzwinel
kdzwinel / optimizely.js
Created Jun 17, 2015
Calculating A/B Test Sample Size
View optimizely.js
"use strict";
//based on https://www.optimizely.com/resources/sample-size-calculator/
function getSampleSize() {
let effect = 0.05; // Minimum Detectable Effect
let significance = 0.95; // Statistical Significance
let conversion = 0.05; // Baseline Conversion Rate
let c = conversion - (conversion * effect);
let p = Math.abs(conversion * effect);
@kdzwinel
kdzwinel / main.js
Created Sep 24, 2015
stroke effect generator
View main.js
var color = 'white';
var r = 1.4;//circle readius
var x = -0.15;//circle center
var y = 0.15;
function getXY(angle) {
return {
x: r * Math.cos(angle) + x,
y: r * Math.sin(angle) + y
};
@kdzwinel
kdzwinel / main.js
Last active Oct 21, 2019
List all undefined CSS classes
View main.js
/*
This script attempts to identify all CSS classes mentioned in HTML but not defined in the stylesheets.
In order to use it, just run it in the DevTools console (or add it to DevTools Snippets and run it from there).
Note that this script requires browser to support `fetch` and some ES6 features (fat arrow, Promises, Array.from, Set). You can transpile it to ES5 here: https://babeljs.io/repl/ .
Known limitations:
- it won't be able to take into account some external stylesheets (if CORS isn't set up)
- it will produce false negatives for classes that are mentioned in the comments.
@kdzwinel
kdzwinel / index.js
Created Nov 9, 2015
browser-sync-client Chrome Extension socket
View index.js
"use strict";
var MSG_NAMESPACE = 'browser-sync';
var port = chrome.runtime.connect({name: MSG_NAMESPACE});
/**
* @returns {string}
*/
exports.getPath = function () {
return window.location.pathname;
View index.html
<head>
...
<meta name="viewport" content="width=device-width">
...
</head>
You can’t perform that action at this time.