Skip to content

Instantly share code, notes, and snippets.

View MartijnHols's full-sized avatar
😄
Hoi!

Martijn Hols MartijnHols

😄
Hoi!
View GitHub Profile
@MartijnHols
MartijnHols / useDocumentHeight.ts
Last active April 6, 2024 16:51
React hooks for getting the document height that updates when the On Screen Keyboard/Virtual Keyboard toggles
The latest version is available at https://martijnhols.nl/gists/how-to-get-document-height-ios-safari-osk
@MartijnHols
MartijnHols / iosedgedragnavigationmonitor.md
Last active July 25, 2022 15:18
iOS edge drag navigation monitor

Using a transition to open screens helps users keep track of where they are and mimicks the native apps they're used to.

2021-11-11 09 58 48

But on iOS Safari this leads to an issue. In Safari users can drag the edges of the screen to navigate to the previous and next page. This also works on iOS in native apps to close "pushed" screens (screens that animate in from the left). Keeping this behavior in place is likely desirable, but this can conflict with custom screen transitions.

2021-11-11 10 06 22

If you pay close attention, you'll see the screen transitions from one side to the other twice. The first is Safari transitioning between the current and previous page neatly with the position of the finger of the user. The second is the transition from our app "catching up". We don't need both transiti

@MartijnHols
MartijnHols / README.md
Last active November 12, 2021 10:28
GraphQL queries over a websocket in Node.js (with TypeScript)

GraphQL over websockets doesn't seem to be widely used yet. There are several libraries, articles and docs available but half of them don't work, require additional new technologies or provide non-standard solutions. I tried to find a simple, reliable and scalable solution that didn't need much more knowledge outside of Apollo, GraphQL and WebSockets. I also don't want it to rely on unrelated libraries like Express so I don't lock myself in. It will probably also benefit the server structure to keep Apollo separate from other modules (sort of like a microservice).

Using apollo-server (while not very performant) seems to be one of the few proven technologies for having a GraphQL backend in Node.js. Using that on the server is probably going to provide the quickest road to production, as it's widely used it will probably have decent documentation and issues can probably be solved by a few Google queries. I

@MartijnHols
MartijnHols / oldCooldownUsable.test.js
Created October 3, 2017 19:41
oldCooldownUsable.test.js
import SPELLS from 'common/SPELLS';
import CooldownUsable from './CooldownUsable';
describe('Core/Modules/CooldownUsable', () => {
let instance;
let combatantsMock;
let castEfficiencyMock;
let hasteMock;
beforeEach(() => {