Skip to content

Instantly share code, notes, and snippets.

View JigneshPatel's full-sized avatar

Jignesh Fadadu JigneshPatel

View GitHub Profile
@JigneshPatel
JigneshPatel / 01 - AxiosInterceptor.js
Created June 14, 2024 16:53 — forked from usmanshaikh/01 - AxiosInterceptor.js
React - Global Loader effect in Axios Interceptor for every API call with JWT Refresh Token functionality.
// Create AxiosInterceptor component & axiosInstance.
import { useEffect, useState } from "react";
import { useGlobalContext } from "../utils/hooks";
import { useNavigate } from "react-router-dom";
import axios from "axios";
import * as Helpers from "../utils/Helpers";
import constants from "../utils/constants";
import AuthAPI from "./AuthAPI";
const axiosInstance = axios.create({
@JigneshPatel
JigneshPatel / 01 - AxiosInterceptor.js
Created June 14, 2024 16:53 — forked from usmanshaikh/01 - AxiosInterceptor.js
React - Global Loader effect in Axios Interceptor for every API call with JWT Refresh Token functionality.
// Create AxiosInterceptor component & axiosInstance.
import { useEffect, useState } from "react";
import { useGlobalContext } from "../utils/hooks";
import { useNavigate } from "react-router-dom";
import axios from "axios";
import * as Helpers from "../utils/Helpers";
import constants from "../utils/constants";
import AuthAPI from "./AuthAPI";
const axiosInstance = axios.create({
@JigneshPatel
JigneshPatel / IAPHelper.txt
Created April 20, 2022 10:53 — forked from mitchellporter/IAPHelper.txt
In App Purchase in Swift, with Receipt Validation
import UIKit
import StoreKit
//MARK: SKProductsRequestDelegate
extension IAPHelpers : SKProductsRequestDelegate
{
func productsRequest(request: SKProductsRequest, didReceiveResponse response: SKProductsResponse)
{
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
let monitor = NWPathMonitor()
/* closure called when path changes */
let pathUpdateHandler = {(path:NWPath) in
let availableInterfaces = path.availableInterfaces
if !availableInterfaces.isEmpty {
//e.g. [ipsec4, en0, pdp_ip0]
let list = availableInterfaces.map { $0.debugDescription }.joined(separator: "\n")
}
@JigneshPatel
JigneshPatel / JSONCodable+JSONObjects.swift
Created November 10, 2020 19:24 — forked from scottrhoyt/JSONCodable+JSONObjects.swift
A Swift 4 extension for JSONEncoder and JSONDecoder to enable serialization to/deserialization from JSON Objects (e.g. [String: Any])
import Foundation
extension JSONEncoder {
func encodeJSONObject<T: Encodable>(_ value: T, options opt: JSONSerialization.ReadingOptions = []) throws -> Any {
let data = try encode(value)
return try JSONSerialization.jsonObject(with: data, options: opt)
}
}
extension JSONDecoder {
@JigneshPatel
JigneshPatel / us-states-array
Created August 26, 2020 09:59 — forked from iamjason/us-states-array
Swift US States Array
let state = [ "AK - Alaska",
"AL - Alabama",
"AR - Arkansas",
"AS - American Samoa",
"AZ - Arizona",
"CA - California",
"CO - Colorado",
"CT - Connecticut",
"DC - District of Columbia",
"DE - Delaware",
@JigneshPatel
JigneshPatel / UISearchBar.m
Created May 15, 2020 08:18 — forked from jeksys/UISearchBar.m
Detecting when clear is clicked in UISearchBar (X button)
- (void)viewDidLoad {
//find the UITextField view within searchBar (outlet to UISearchBar)
//and assign self as delegate
for (UIView *view in searchBar.subviews){
if ([view isKindOfClass: [UITextField class]]) {
UITextField *tf = (UITextField *)view;
tf.delegate = self;
break;
}
}
@JigneshPatel
JigneshPatel / QRCodeScanner.m
Created April 27, 2020 08:40 — forked from snej/QRCodeScanner.m
Snippet showing how to capture QR codes from the device camera on iOS or Mac OS X
- (BOOL) startCapture: (NSError**)outError {
if (!_session) {
_session = [[AVCaptureSession alloc] init];
AVCaptureDevice* video = [AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeVideo];
if (!video)
return [self failWithMessage: @"No video camera available" error: outError];
AVCaptureDeviceInput* input = [AVCaptureDeviceInput deviceInputWithDevice: video
error: outError];
if (!input)
return [self failWithMessage: @"Couldn't acquire input device" error: outError];
@JigneshPatel
JigneshPatel / UIDevice+XMUtils.h
Created April 27, 2020 07:09 — forked from kangzubin/UIDevice+XMUtils.h
The sample code to get iPhone device name.
//
// UIDevice+XMUtils.h
// AwesomeTips
//
// Created by kangzubin on 2018/9/20.
// Copyright © 2018 KANGZUBIN. All rights reserved.
//
#import <UIKit/UIKit.h>