Skip to content

Instantly share code, notes, and snippets.

View efstathiosntonas's full-sized avatar

Stathis Ntonas efstathiosntonas

View GitHub Profile
@GavinRay97
GavinRay97 / auth.module.ts
Last active February 22, 2024 10:57
Hasura Nest.js JWT Auth utils (REST + GQL)
import { Module } from '@nestjs/common'
import { AuthService } from './auth.service'
@Module({
providers: [AuthService],
exports: [AuthService],
})
export class AuthModule {}
function useCachedAbortiveQuery<T>(
query: DocumentNode,
variables: Record<string, unknown>,
deps: Array<any>
) {
const apolloClient = useApolloClient();
const [data, setData] = useState<T>();
const [error, setError] = useState<Error | null>(null);
const [loading, setLoading] = useState<boolean>(true);
@bokwoon95
bokwoon95 / comments.sql
Last active February 28, 2025 17:38
how to model threaded comments (e.g. reddit comments) in SQL with a simple 'ancestors' column
-- how to model threaded comments (e.g. reddit comments) in SQL with a simple 'ancestors' column
-- The comment tree:
-- [1]
-- / \
-- [2] [4]
-- / \ \
-- [3] [7] [6]
-- /
-- [5]
import React, {
useCallback,
useEffect,
useState,
FunctionComponent,
ComponentClass,
useMemo,
useRef,
Key
} from 'react';
render (): React$Element<Object> {
let {user, kid, goal, balance} = this.props
let currentLevel = this.getCurrentLevel()
if (!goal) return this.renderEmptyState()
let pipes = this.getPipes(goal, kid, user, currentLevel, this.getLevelToClimbTo())
return <View style={{flex: 1}}>
<ColorFix color={colors.stratos} />
<ColorFix isBottom color={colors.fiftyShades} />
<Animated.ScrollView ref={this.setScrollRef} onScroll={this.onScroll} scrollEventThrottle={16} contentContainerStyle={styles.scrollContainer} style={styles.container}>
<LinearGradient style={styles.backgroundImageView} colors={[colors.stratos, colors.stratos, colors.kingfisherDaisy]}>
import React, { useState, useRef, useContext, useCallback } from 'react';
import { Dimensions, View, Animated } from 'react-native';
import { TabView } from 'react-native-tab-view';
import { TabScreen } from './Tab';
import { CustomTabBar } from './TabBar';
import { ThemeContext } from 'react-native-elements';
import { useHeaderHeight } from '@react-navigation/stack';
const AnimatedHeader = ({ style, content }) => {
return <Animated.View style={style}>{content}</Animated.View>;
};
/** UI element heights which used in message height calculation */
textPaddingVertical: number = 7;
textPaddingHorizontal: number = 10;
timeHeight: number = 12;
timeTopMargin: number = 5;
messageContainerVerticalMargin: number = 7;
dateSeperatorVerticalMargin: number = 20;
dateSeperatorHeight: number = 15;
imageHeight: number = 170;
imageBottomMargin: number = 10;
@mrousavy
mrousavy / react-navigation-shared-element-v5-guide.md
Last active June 12, 2022 12:56
React Navigation Shared Element v5 Guide

How to use React Navigation Shared Element v5

Install

Run:

npm i react-navigation-shared-element@next react-native-shared-element
npm i @react-navigation/native@^5.0.9 @react-navigation/stack@^5.1.1
const LastSongs = (props) => {
const [songs, setSongs] = React.useState([]);
const [loading, setLoading] = React.useState(false);
const [page, setPage] = React.useState(1);
const [last_page, setLast_page] = React.useState(1);
const {saveSongs, isPlaying, isPauseTrigger} = props;
const _renderItems = useCallback(
@pie6k
pie6k / package.json
Created January 28, 2020 05:24
Timpler package.json
{
"name": "Timpler",
"version": "0.0.1",
"private": true,
"scripts": {
"a": "cd ./android && ./gradlew app:assembleDebug && ./gradlew installDebug",
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",