Skip to content

Instantly share code, notes, and snippets.

View PatrickJS's full-sized avatar

PatrickJS PatrickJS

View GitHub Profile

Keybase proof

I hereby claim:

  • I am patrickjs on github.
  • I am patrickjs (https://keybase.io/patrickjs) on keybase.
  • I have a public key ASBn2MGzPQqMCt802JVdIQZ4jMYLE-gPnJ4uBCai7-XQxgo

To claim this, I am signing this object:

class LRU extends Map {
m = 10;
get(k) {
let i = super.get(k);
if (i) {
super.delete(k);
super.set(k, i);
}
return i;
}
@PatrickJS
PatrickJS / utils.ts
Created August 9, 2020 11:13
angular/packages/elements/src/utils.ts
let matches = null;
export function matchesSelector(element: Element, selector: string): boolean {
if (!matches) {
const elProto = Element.prototype as any;
matches = elProto.matches || elProto.matchesSelector || elProto.mozMatchesSelector ||
elProto.msMatchesSelector || elProto.oMatchesSelector || elProto.webkitMatchesSelector;
}
return matches.call(element, selector);
}
@PatrickJS
PatrickJS / zoom-bombing.php
Created April 3, 2020 17:26 — forked from nekromoff/zoom-bombing.php
Zoom bombing - identify Zoom existing meeting IDs
<?php
/*
Identify existing meetings/meeting IDs on Zoom.us call app
License: Public domain. Use for pranking only. Any other use prohibited.
https://gist.github.com/nekromoff/48ec26cbaecc31fccb202d1efa7d0657
*/
$ch = curl_init();
export const h=(t,p,...c)=>({t,p,c,k:p&&p.key})
export const render=(e,d,t=d.t||(d.t={}),p,r,c)=>
// arrays
e.pop?e.map((e,p)=>render(e,d,t.o&&t.o[p])):
// components
e.t.call?(e.i=render((render.c=e).t({children:e.c,...e.p},e.s=t.s||{},t=>
render(Object.assign(e.s,t)&&e,d,e)),t.i||d,t&&t.i||{}),e):(
// create notes
e.d=t.d||(e.t?document.createElement(e.t):new Text(e.p)),
// diff props
const { createServer } = require('http');
createServer((req, res) => {
res.writeHead(200, {
Connection: 'Transfer-Encoding',
'Content-Type': 'text/html; charset=utf-8',
'Transfer-Encoding': 'chunked'
});
res.write(`
@PatrickJS
PatrickJS / service-workers.md
Last active September 3, 2020 04:53 — forked from Rich-Harris/service-workers.md
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

/* eslint-disable no-param-reassign */
const path = require('path');
const fse = require('fs-extra');
class LoadablePlugin {
constructor({ filename = 'loadable-stats.json', writeToFileEmit = false } = {}) {
this.opts = { filename, writeToFileEmit };
}
apply(compiler) {
@PatrickJS
PatrickJS / 1.js
Created September 14, 2018 19:19 — forked from getify/1.js
tag function for formatting console.log(..) statements
function logger(strings,...values) {
var str = "";
for (let i = 0; i < strings.length; i++) {
if (i > 0) {
if (values[i-1] && typeof values[i-1] == "object") {
if (values[i-1] instanceof Error) {
if (values[i-1].stack) {
str += values[i-1].stack;
continue;
}
@PatrickJS
PatrickJS / AWSRegionsAndAZs.md
Created September 14, 2018 07:05
List of AWS availability zones for each AWS region
AWS region code AWS region name Number of AZs AZ names
us-east-1 Virginia 4 us-east-1a, us-east-1b, us-east-1c, us-east-1e
us-west-1 N. California 2 us-west-1a, us-west-1b
us-west-2 Oregon 3 us-west-2a, us-west-2b, us-west-2c
eu-west-1 Ireland 3 eu-west-1a, eu-west-1b, eu-west-1c
eu-central-1 Frankfurt 2 eu-central-1a, eu-central-1b
ap-southeast-1 Singapore 2 ap-southeast-1a, ap-southeast-1b
ap-southeast-2 Sydney 2 ap-southeast-2a, ap-southeast-2b, ap-southeast-2c
ap-northeast-1 Tokyo 2 ap-northeast-1a, ap-nort