Skip to content

Instantly share code, notes, and snippets.

View NileshPatel17's full-sized avatar

Nilesh Patel NileshPatel17

View GitHub Profile

Credit Card Payment Form

Wanted to work with some masking so made a payment form so, using vanilla JS and the imask.js library, made a fairly simply payment form that uses regex patterns to detect the credit card type as the user is inputting values and properly applies the relevant spacing associated with that brand. Also wanted to do a smidge of style flair so made a simple SVG card that changes as the user fills out the form.

A Pen by Adam Quinlan on CodePen.

License.

@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 / vscide-settings.md
Last active October 19, 2021 04:43
vscode-settings

Vs Code Settings

Configure native bracket pair colourization

  1. Make sure to remove the Bracket Pair Colorizer extension. Update VS Code
  2. Open your user settings via CMD (CTRL for non-Mac users) + Shift + P and type settings. The settings JSON file will open. Add the following:
"editor.bracketPairColorization.enabled": true
@NileshPatel17
NileshPatel17 / git-multiple-accounts.md
Last active October 18, 2021 12:58
git-multiple-accounts

git-multiple-accounts

step 1:

  1. edit ~/.gitconfig

cat ~/.gitconfig

[user]
   name = Nilesh Patel
@NileshPatel17
NileshPatel17 / react-native-svg-circle.md
Last active September 24, 2021 05:31
react-native-animation-circle
import React from 'react';
import { View, Button, Text, Animated, StyleSheet, Easing } from 'react-native';
import Svg, { Circle } from 'react-native-svg';

const AnimatedCircle = Animated.createAnimatedComponent(Circle);

export function Box() {
  const animationController = React.useRef(new Animated.Value(0)).current;
  React.useEffect(() => {
@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,
@NileshPatel17
NileshPatel17 / useful-docker-commands.md
Last active October 1, 2021 08:07
useful-docker-commands.md

Docker commands:

kill all running containers

docker kill $(docker ps -q)

delete all stopped containers

docker rm $(docker ps -a -q)

delete all images