Skip to content

Instantly share code, notes, and snippets.

View NileshPatel17's full-sized avatar

Nilesh Patel NileshPatel17

View GitHub Profile
@NileshPatel17
NileshPatel17 / api_generator.js
Created April 1, 2022 09:31 — forked from v1vendi/api_generator.js
REST API functional generator
const fetch = (...args) => console.log(...args) // mock
function httpRequest(url, method, data) {
const init = { method }
switch (method) {
case 'GET':
if (data) url = `${url}?${new URLSearchParams(data)}`
break
case 'POST':
case 'PUT':
case 'PATCH':
import { useEffect, useRef } from "react";
import { AppState, AppStateStatus } from "react-native";
export const useFetchOnAppForeground = () => {
const listener = useRef(null);
function fetchOnAppForeground(params) {
if (AppState.currentState === "active") {
return fetch(params);
} else {
@NileshPatel17
NileshPatel17 / App.tsx
Created January 7, 2022 18:52 — forked from intergalacticspacehighway/App.tsx
Add row/col gaps in flatlist
function App() {
const data = Array(10).fill(0);
const GAP = 5;
const numColumns = 3;
const { width } = Dimensions.get("window");
// Reduce the size to accomodate margin space by items
const ITEM_SIZE = width / numColumns - ((numColumns - 1) * GAP) / numColumns;
const renderItem = ({ index }) => {
@NileshPatel17
NileshPatel17 / PinchToZoom.tsx
Created December 30, 2021 12:03 — forked from intergalacticspacehighway/PinchToZoom.tsx
Pinch to zoom reanimated + gesture handler
import React, { useMemo, useState } from "react";
import { LayoutChangeEvent, StyleSheet } from "react-native";
import {
PinchGestureHandler,
PinchGestureHandlerGestureEvent,
} from "react-native-gesture-handler";
import Animated, {
useAnimatedGestureHandler,
useAnimatedStyle,
useSharedValue,
@NileshPatel17
NileshPatel17 / settings.json
Created September 2, 2021 11:36 — forked from mrousavy/settings.json
My VSCode settings + themes + extensions
// VSCode Settings (hit `Cmd + ,` to open settings)
{
"editor.smoothScrolling": true,
"editor.fontSize": 16,
"editor.fontFamily": "Fira Mono, Consolas, 'Courier New', monospace",
"editor.wordWrap": "on",
"editor.tabCompletion": "on",
"explorer.openEditors.visible": 0,
"explorer.autoReveal": false,
// Expo SDK41
// expo-blur: ~9.0.3
import React, { useRef } from 'react';
import {
Animated,
Image,
ImageBackground,
ScrollView,
StatusBar,
@NileshPatel17
NileshPatel17 / arrayPagination.js
Created June 21, 2021 07:42 — forked from Falciighol/arrayPagination.js
[Array pagination] Slice an array with the page size and page number params #javascript #js
function paginate(array, page_size, page_number) {
// human-readable page numbers usually start with 1, so we reduce 1 in the first argument
return array.slice((page_number - 1) * page_size, page_number * page_size);
}
console.log(paginate([1, 2, 3, 4, 5, 6], 2, 2));
console.log(paginate([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 4, 1));
@NileshPatel17
NileshPatel17 / Example.tsx
Created January 4, 2021 14:29 — forked from stolinski/Example.tsx
Route Transitions with Framer Motion
const FakeComponent = () => {
return (
<AnimatedRoutes exitBeforeEnter initial={false}>
<RouteTransition exact path="/some-route">
<NewUsers />
</RouteTransition>
<RouteTransition exact path="/yo" >
<Users />
</RouteTransition>
</AnimatedRoutes>
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew cask install iterm2
# update iterm2 settings -> colors, keep directory open new shell, keyboard shortcuts
brew install bash # latest version of bash
# set brew bash as default shell
brew install fortune
brew install cowsay
brew install git

Dev Setup

  1. Homebrew/terminal/bash
  2. OSX Productivity - Window Management/Quick Launcher/Hyperswitch
  3. OSX Settings - Dock/Finder
  4. Web Browser - Extensions - AdBlock, Privacy Badger, OneTab, JSONViewer, Stylus, Vue Devtools, React Devtools
  5. Node.js - nvm
  6. Code Editor - vs code
  7. Code Editor Extensions
  8. Break timer and Flux