Skip to content

Instantly share code, notes, and snippets.

Paul Kinlan PaulKinlan

Block or report user

Report or block PaulKinlan

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
@PaulKinlan
PaulKinlan / devicelab.sh
Last active Dec 12, 2015
Launch the same page across multiple connected Android devices. ./devicelab.sh http://paul.kinlan.me/
View devicelab.sh
#!/bin/sh
# Usage:
# Open browser on all connected devices -
# ./devicelab.sh
# Open a url on all connected devices -
# ./devicelab.sh http://paul.kinlan.me/
adb kill-server
port=9220
@PaulKinlan
PaulKinlan / RGBtoHSL.js
Last active Jun 1, 2016
Coverts RGB values to HSL
View RGBtoHSL.js
const RGBToHSL = (r,g,b) => {
// Algo http://www.rapidtables.com/convert/color/rgb-to-hsl.htm
const [r1,g1,b1] = [r/255, g/255, b/255];
const [cmax, cmin] = [Math.max(r1,g1,b1), Math.min(r1,g1,b1)];
const d = (cmax - cmin);
const L = (cmax + cmin) / 2;
const S = d == 0 ? 0 : (d / ( 1 - Math.abs(2*L-1)));
const H = d == 0 ? 0 :
@PaulKinlan
PaulKinlan / HSLToRGB.js
Last active Jun 1, 2016
Converts an HSL value to RGB
View HSLToRGB.js
const HSLToRBG = (H, S, L) => {
// algo http://www.rapidtables.com/convert/color/hsl-to-rgb.htm
const C = (1 - Math.abs(2*L - 1)) * S;
const X = C * (1 - Math.abs(((H / 60) % 2)-1));
const m = L - C/2;
const [r1, g1, b1] = H >= 0 && H < 60 ? [C, X, 0] :
H >= 60 && H < 120 ? [X, C, 0] :
H >= 120 && H < 180 ? [0, C, X] :
H >= 180 && H < 240 ? [0, X, C] :
View dataUriForStylesheet.js
var toDataURI = function(datatype, data) {
return "data:" + datatype +";base64," + window.btoa(data);
};
var renderStyleSheet = function() {
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = toDataUri("text/css", "body { background-color: red;}" );
document.head.appendChild(link);
};
@PaulKinlan
PaulKinlan / unregister-service-worker.js
Last active Jun 1, 2016
unregister-service-worker bookmarklet
View unregister-service-worker.js
javascript: (function()%20%7B%20%0A%20%20%20%20console.log(%22test%22)%3B%0A%20%20%20%20var%20sw%20%3D%20navigator.serviceWorker%3B%0A%20%20%20%20if%20(sw.controller)%20%7B%0A%20%20%20%20%20%20sw.getRegistration(document.location).then(function(reg)%20%7B%20return%20reg.unregister()%3B%20%7D).then(function()%20%7B%20console.log(%22Unregister%20Successful%22)%20%7D).catch(function(e)%20%7B%20console.log(%22No%20Service%20Worker%3A%20%22%20%2B%20e)%7D)%3B%0A%20%20%20%20%7D%0A%20%20%7D())
View designer.html
<script
src="/components/platform/platform.js">
</script>
<link rel="import"
href="/components/core-toolbar/core-toolbar.html">
<link rel="import"
href="/components/core-menu/core-menu.html">
<link rel="import"
href="/components/core-item/core-item.html">
<link rel="import"
@PaulKinlan
PaulKinlan / dabblet.css
Created Jul 19, 2012
The first commented line is your dabblet’s title
View dabblet.css
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
View gist:2854138
var i = new Intent({
"action": "http://webintents.org/save",
"type": "text/uri-list",
"data": "http://placekitten.com/g/200/300"
})
var onsuccess = function(data) {
};
var onerror = function(){ };
View gist:2853982
var i = new Intent({
"action": "http://webintents.org/save",
"type": "image/*",
"extras": { "url": "http://placekitten.com/g/200/300" }
})
var onsuccess = function(data) {
var img1 = document.getElementById("img1");
if(data instanceof Blob) {
img1.src = URL.createObjectURL(data);
View gist:2853874
window.addEventListener("load", function() {
if(window.intent && window.intent.action === "http://webintents.org/save") {
var data = window.intent.data;
if(data instanceof Blob) {
// do something with the blob.
}
else {
// do something with the object.
You can’t perform that action at this time.