Skip to content

Instantly share code, notes, and snippets.

View efstathiosntonas's full-sized avatar

Stathis Ntonas efstathiosntonas

View GitHub Profile
@derekstavis
derekstavis / FastList.tsx
Last active August 7, 2025 17:52 — forked from vishnevskiy/FastList.js
Discord's FastList, but in TypeScript
import { forEachObjIndexed } from "ramda";
import * as React from "react";
import {
Animated,
ScrollView,
View,
ViewStyle,
LayoutChangeEvent,
NativeScrollEvent,
} from "react-native";
@Danziger
Danziger / interval.hook.ts
Last active November 15, 2023 18:00
✨ Declarative useTimeout (setTimeout), useInterval (setInterval) and useThrottledCallback (useCallback combined with setTimeout) hooks for React (in Typescript)
import React, { useEffect, useRef } from 'react';
/**
* Use setInterval with Hooks in a declarative way.
*
* @see https://stackoverflow.com/a/59274004/3723993
* @see https://overreacted.io/making-setinterval-declarative-with-react-hooks/
*/
export function useInterval(
callback: React.EffectCallback,
const express = require('express');
const app = express();
// Application
app.get('/', function(req, res) {
if (process.env.NODE_ENV === 'development') {
for (var key in require.cache) {
delete require.cache[key];
}
}
// we have a LOGOUT action that will reset the whole state
// HACK: When state is recreated, it will loose '_persist' in it, and the state will not be persisted anymore.
// Dispatching 'persist/REHYDRATE' makes persistence work again somehow, so we dispatch it to all persisted keys.
const storageKeys = yield call(storage.getAllKeys);
const persistKeys = (storageKeys.map((key: string) => {
const regexp = new RegExp('^persist:(.+)');
if (key.match(regexp)) {
return RegExp.$1;
}
@zenz
zenz / react.gradle
Last active November 23, 2019 01:34
temporary fix for hermes-engine working with Windows
// Copyright (c) Facebook, Inc. and its affiliates.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
import org.apache.tools.ant.taskdefs.condition.Os
def config = project.hasProperty("react") ? project.react : [];
def cliPath = config.cliPath ?: "node_modules/react-native/cli.js"
@ngryman
ngryman / example.ts
Created June 29, 2019 17:24
Updating cached data from multiple parameterized queries after a mutation (hacky solution)
addTask({
variables: { input },
optimisticResponse: {
addTask: {
__typename: 'Task',
id,
...input
}
},
update: (proxy: any, { data: { addTask } }: any) => {
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { Image, StyleSheet, Dimensions } from 'react-native';
import FastImage from 'react-native-fast-image';
import ImageZoom from 'react-native-image-pan-zoom';
// ZoomableImage component renders a zoomable FastImage the size of the screen dimensions.
const dims = Dimensions.get('window');
@jakewtaylor
jakewtaylor / usage.jsx
Last active August 31, 2022 18:21
useStyles() React Hook
import React from 'react';
import { useStyles } from '../hooks/useStyles';
export const Sidebar = ({ colourful = false }) => {
const styles = useStyles(stylesheet);
return (
<div className={styles.sidebar}>
<p
className={styles.compose(
@a-barbieri
a-barbieri / README.md
Last active June 6, 2021 21:48
NextJS sitemap generator with dynamic URL

NextJS sitemap generator

Install

The current setup has been tested on Next Js 7.0.0.

You need to install Axios.

$ npm install axios
@CaiJimmy
CaiJimmy / cloud-function--http.js
Last active May 4, 2020 09:16
Firebase pagination
/* HTTP Function to initialize / reset question counter manually */
const express = require('express');
const cors = require('cors')({
origin: true
});
const app = express();
app.use(cors);
app.get('/', (req, res) => {
const topicID = req.query.topicID,