View gist:841bfc0ba6f55e0f997e37b7a6db4714
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* A DECORATOR TO NOTIFY ABOUT UNUSUALLY LONG ASYNC CALLS */ | |
/* Let your user and your error-reporting know when a network call takes unusually long */ | |
// HOW TO USE: | |
/* | |
const makeCall = observe(.... my function to make an async call, e.g. network....., opts, takes longer, takes much longer, takes way too long) | |
// example: const observedFetch = observe(fetch, {id: 'my-api-calls'}, () => console.log('This is taking a little longer than usual'), () => console.log('This is taking a longer than usual'), () => console.log('This is taking a much longer than usual')); | |
// Then proceed as usual | |
makeCall(....); // or observedFetch('https://example.com').then(i => i.text()).then(i => console.log(i)); | |
// for the "takes longer" callbacks, you can react how you want, e.g., you could hook a notification system in! |
View day7.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Day7 do | |
@maxsize 100000 | |
@total 70000000 | |
@needspace 30000000 | |
@moduledoc """ | |
Documentation for `Day7`. | |
""" | |
@doc """ |
View Advent of Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Day 1 - Part 1 | |
Math.max(...document.body.innerText.split("\n\n").map(i => i.split("\n").filter(i=>i.trim()).reduce((p, q) => p + parseInt(q), 0))) | |
// Day 1 - Part 2 | |
document.body.innerText.split("\n\n").map(i => i.split("\n").filter(i=>i.trim()).reduce((p, q) => p + parseInt(q), 0)).sort((a,b) => a-b).slice(-3).reduce((a, b)=>a+b, 0) | |
// Day 2 - Part 1 | |
pmap = {X: 1, Y: 2, Z: 3} | |
wmap={'A X': 3, 'B Y': 3, 'C Z': 3, 'A Y': 6, 'A Z': 0, 'B Z': 6, 'B X': 0, 'C X': 6, 'C Y': 0} | |
document.body.innerText.split('\n').filter(i => i.trim()).map(i => wmap[i.trim()] + pmap[i.trim()[i.trim().length - 1]]).reduce((p, i) => p+i, 0) | |
// Day 2 - Part 2 | |
wmap2={'A X': 'Z', 'B X': 'X', 'C X': 'Y', 'B Y': 'Y', 'A Y': 'X', 'C Y': 'Z', 'C Z': 'X', 'B Z': 'Z', 'A Z': 'Y'} |
View cloud-init-with-ufw-and-nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
users: | |
- name: <USERNAME> | |
ssh-authorized-keys: | |
- ssh-rsa <PUBLIC SSH KEY> | |
sudo: ['ALL=(ALL) NOPASSWD:ALL'] | |
groups: sudo | |
shell: /bin/bash | |
package_update: true | |
package_upgrade: true |
View EventTarget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EventTarget { | |
constructor(options) { | |
if(options) { | |
Object.assign(this, options); | |
} | |
this.listeners = {}; | |
} | |
addEventListener (type, callback, useCaptureOptions) { | |
if (!(type in this.listeners)) { |
View After + First
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see https://mongoplayground.net/p/hrVd5xrWBbh | |
db.collection.aggregate([ | |
{ | |
$match: { | |
...preconditions... | |
} | |
}, | |
{ | |
$sort: { | |
_id: 1 |
View Relay Cursor Spec Pagination in SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- --------------------- CREATE TABLE ------------------- | |
-- Table: public.pagination | |
CREATE TABLE IF NOT EXISTS public.pagination | |
( | |
uuid uuid NOT NULL DEFAULT gen_random_uuid(), | |
ts timestamp without time zone NOT NULL DEFAULT now(), | |
-- any columns | |
data jsonb NOT NULL, | |
View gist:b0c0b9d3918ef7cd71a5dc199975e756
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am zyclotrop-j on github. | |
* I am zyclotrop (https://keybase.io/zyclotrop) on keybase. | |
* I have a public key ASAkllhs7vILmYio6WAfl6tXemFysGVS5I7AsIPFJrKy3Qo | |
To claim this, I am signing this object: |