Skip to content

Instantly share code, notes, and snippets.

Avatar
⛩️
hizenapp.com

PatrickJS PatrickJS

⛩️
hizenapp.com
View GitHub Profile
@PatrickJS
PatrickJS / haproxy.config
Created Jan 25, 2021 — forked from bwiggs/haproxy.config
HAProxy Config File Example
View haproxy.config
global
#debug # uncomment to enable debug mode for HAProxy
defaults
mode http # enable http mode which gives of layer 7 filtering
timeout connect 5000ms # max time to wait for a connection attempt to a server to succeed
timeout client 50000ms # max inactivity time on the client side
timeout server 50000ms # max inactivity time on the server side
backend legacy # define a group of backend servers to handle legacy requests
View GetOptimizationStatus.md

%GetOptimizationStatus return a set of bitwise flags instead of a single value, to access the value, you need to take the binary representation of the returned value. Now, for example, if 65 is returned, the binary representation is the following:

(65).toString(2).padStart(12, '0');
// 000001000001

Each binary digit acts as a boolean with the following meaning:

@PatrickJS
PatrickJS / expired-map.ts
Last active Aug 31, 2020
this doesn't work in cloudflare workers where time doesn't change
View expired-map.ts
export class ExpireMap extends Map {
expiring = new Map()
constructor(private _millis: number, private _getTime = this._getTime) {
super()
}
public set<T, V>(key: T, value: V): V {
const expire = this.getTime() + this._millis
this.expiring.set(key, expire)
super.set(key, value)
View deno-lru.ts
export class LRU extends Map {
constructor(private max: number) {
super();
}
/**
* Attemps to retrieve a value from the cache
* @param key The key of the entry to return from the cache
* @returns the value associated to the input key or undefined
*/
View keybase.md

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:

View map-lru.ts
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 Aug 9, 2020
angular/packages/elements/src/utils.ts
View 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 Apr 3, 2020 — forked from nekromoff/zoom-bombing.php
Zoom bombing - identify Zoom existing meeting IDs
View zoom-bombing.php
<?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();
View little-vdom.js
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