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 / main.py
Created Oct 11, 2016
BBC Micro:bit Arkanoid clone
View main.py
from microbit import *
# quickly create a level of two rows, with pixels set to 0 hits and 1 hits
blocks = [[1 - i for j in range(5) ] for i in range(2)]
ball = [2, 3]
ball_direction = [1,-1]
paddle = [2, 4]
previous_game_time = running_time()
ball_timing = running_time()
game_time = running_time()
@PaulKinlan
PaulKinlan / manifest-polyfill.html
Last active Feb 27, 2018
Web App Manifest Polyfill for iOS
View manifest-polyfill.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="manifest" href="https://jsbin-user-assets.s3.amazonaws.com/kinlan/manifest.json">
<title>iOS Manifest Polyfill</title>
</head>
<body>
@PaulKinlan
PaulKinlan / add-to-homescreen-test.html
Last active Apr 18, 2019
iOS Add to Homescreen => simulate web app manifest
View add-to-homescreen-test.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Add to Homescreen</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="Test name 2">
@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] :
@PaulKinlan
PaulKinlan / bookmark.js
Last active Jun 27, 2016
Progressive Web App Checklist
View bookmark.js
(function() {
var ManifestParser = (function() {
'use strict';
var _jsonInput = {};
var _manifest = {};
var _logs = [];
var _tips = [];
var _success = true;
@PaulKinlan
PaulKinlan / install.js
Last active Sep 9, 2016
window.install
View install.js
(function() {
var deferredInstall;
var promptTriggered = false;
// The resolve function that will be called when we know we can prompt.
var canPromptPromiseResolved;
var canPromptPromise = new Promise(function(resolve, reject) {
// The resolve will be called later when we know the prompt has been shown.
// We might want to reject after a timeout of a couple of seconds.
canPromptPromiseResolved = resolve;
@PaulKinlan
PaulKinlan / getdeviceart.sh
Last active May 24, 2019
Screen Record for Android
View getdeviceart.sh
#! /bin/bash
mkdir -p ./backgrounds
function get_google_device_art {
local device=$1
# Get the Google Device backgrounds
curl "https://developer.android.com/distribute/marketing-tools/device-art-resources/$1/port_back.png" > "./backgrounds/$1_port_back.png"
curl "https://developer.android.com/distribute/marketing-tools/device-art-resources/$1/port_fore.png" > "./backgrounds/$1_port_fore.png"
@PaulKinlan
PaulKinlan / prefetchbuilder.js
Last active Jan 2, 2017
Code to return link rel=dnsprefetch
View prefetchbuilder.js
(function() {
var requests = window.performance.getEntries();
var hosts = {};
var output = "";
for(var requestIdx = 0; requestIdx < requests.length; requestIdx++) {
var request = requests[requestIdx];
var origin = new URL(request.name).origin;
hosts[origin] = 1;
@PaulKinlan
PaulKinlan / detect.js
Created Mar 5, 2015
Detect unknown content injection
View detect.js
var detectInjection = function(knownHostsArray) {
var requests = window.performance.getEntriesByType("resource");
var unknownHosts = [];
var knownHosts = {};
var foundHosts = {};
for (var knownHost in knownHostsArray) {
knownHosts[knownHostsArray[knownHost]] = true;
}
You can’t perform that action at this time.