Skip to content

Instantly share code, notes, and snippets.

View Andarius's full-sized avatar

Julien Brayere Andarius

View GitHub Profile
@nelsonprsousa
nelsonprsousa / useScrollToTop.ts
Last active January 29, 2022 15:30
The expected native behavior of scrollable components is to respond to events from navigation that will scroll to top when tapping on the active tab as you would expect from native tab bars. Works with react-native-navigation.
import { useEffect, useRef } from 'react';
import { ScrollView } from 'react-native';
import { Navigation } from 'react-native-navigation';
const useScrollToTop = ({
selectedTabIndex,
}: {
selectedTabIndex: number;
}): React.RefObject<ScrollView> => {
const scrollViewRef = useRef<ScrollView>(null);
@fphilipe
fphilipe / exclude.sql
Last active November 6, 2024 17:12
PostgreSQL EXCLUDE constraint
CREATE EXTENSION btree_gist;
CREATE TABLE room_reservations (
room_id integer,
reserved_at timestamptz,
reserved_until timestamptz,
canceled boolean DEFAULT false,
EXCLUDE USING gist (
room_id WITH =, tstzrange(reserved_at, reserved_until) WITH &&
) WHERE (not canceled)