Skip to content

Instantly share code, notes, and snippets.

View anujraghuvanshi's full-sized avatar
🤞
Good* Better** Best***. Never let it rest, Till your *=>** && **=>***

Anuj Raghuvanshi anujraghuvanshi

🤞
Good* Better** Best***. Never let it rest, Till your *=>** && **=>***
View GitHub Profile
@anujraghuvanshi
anujraghuvanshi / store.js
Created July 16, 2021 04:56 — forked from steniowagner/store.js
Basic setup of Redux-Store + Redux-Persist + Redux-Saga. You can find a snippet that use this configuration here: https://gist.github.com/steniowagner/e778fcae0d8eb77b82da983fb46c2826
import { createStore, applyMiddleware, compose } from 'redux';
import createSagaMiddleware from 'redux-saga';
import { persistStore, persistCombineReducers } from 'redux-persist';
import storage from 'redux-persist/es/storage';
import rootSaga from './sagas';
/* Reducers */
@anujraghuvanshi
anujraghuvanshi / react-native-responsive.js
Created May 14, 2021 19:31
Responsive design for React Natiive Mobile Apps.
import { Dimensions, StatusBar } from 'react-native';
const { width, height } = Dimensions.get('window');
const guidelineBaseWidth = 375;
const guidelineBaseHeight = 812;
const scale = size => (width / guidelineBaseWidth) * size;
const verticalScale = size => (height / guidelineBaseHeight) * size;
const moderateScale = (size, factor = 0.5) => size + (scale(size) - size) * factor;
const moderateScaleVertical = (size, factor = 0.5) => size + (verticalScale(size) - size) * factor;
@anujraghuvanshi
anujraghuvanshi / detect-device.js
Created April 8, 2021 19:55
Detect Device variant by size in React Native.
import { PixelRatio, Dimensions } from 'react-native'
const detectDevice = (deviceType) => navigator.userAgent.match(deviceType)
const windowSize = Dimensions.get('window')
let pixelDensity = PixelRatio.get()
let width = windowSize.width
let height = windowSize.height
let adjustedWidth = width * pixelDensity
let adjustedHeight = height * pixelDensity
@anujraghuvanshi
anujraghuvanshi / debound-throttle.js
Created April 8, 2021 19:52
Debounce and throttle function - JS.
export function debounce(func, wait, immediate) {
let timeout
return function () {
const context = this,
args = arguments
const later = function () {
timeout = null
if (!immediate) {
func.apply(context, args)
}
@anujraghuvanshi
anujraghuvanshi / RN-properties-overwrite
Created April 8, 2021 19:43
- Ability to modify the behaviour of default props of RN components (Here in this gist, increased font sized globally by 3px)
const setDefaultConfig = () => {
let components = [Text] // Components to modify.
const customProps = { style: {} }
const TextRender = components[0].render
const initialDefaultProps = components[0].constructor.defaultProps
components[0].render = function render(props) {
let oldProps = { ...props }
@anujraghuvanshi
anujraghuvanshi / Apple_mobile_device_types.txt
Created July 26, 2020 21:23 — forked from adamawolf/Apple_mobile_device_types.txt
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
iPhone5,1 : iPhone 5 (GSM)
<?php
session_start();
$LINKEDIN_CFG = array(
'client_id' => 'YOUR_CLIENT_ID',
'client_secret' => 'YOUR_CLIENT_SECRET',
'redirect' => 'http://localhost/nearby-palce-locator/places.php',
'scope' => 'r_liteprofile',
);