Skip to content

Instantly share code, notes, and snippets.

View satishbabariya's full-sized avatar

Satish Babariya satishbabariya

View GitHub Profile
@satishbabariya
satishbabariya / links.txt
Created October 17, 2019 03:06
Ref Links to check
@satishbabariya
satishbabariya / state.js
Last active November 28, 2019 17:44
Using the State Hook
import {useAsync} from 'react-use';
const Demo = ({url}) => {
const state = useAsync(async () => {
const response = await fetch(url);
const result = await response.text();
return result
}, [url]);
return (
/**
* Check user is admin or not
* @param {*} req Express req Object
* @param {*} res Express res Object
* @param {*} next Express next Function
*/
const isAdmin = async (req, res, next) => {
if (!req.currentUser) {
return next(new Exception('Error in checking current user', 500));
export class Events {
static _Listeners = {
count: 0,
refs: {}
};
static addEventListener(eventName: string, callback: () => any) {
Events._Listeners.count++;
const eventId = "l" + Events._Listeners.count;
Events._Listeners.refs[eventId] = {
@satishbabariya
satishbabariya / FlatList.tsx
Created March 27, 2020 11:25
FlatList.tsx
import React from 'react';
import {
SafeAreaView,
TouchableOpacity,
FlatList,
StyleSheet,
Text,
} from 'react-native';
import Constants from 'expo-constants';
@satishbabariya
satishbabariya / Rollup.md
Created May 28, 2020 04:46
Rollup babel setup

Rollup

Rollup represents another recent addition and alternative. Users who've used webpack will find Rollup's configuration familiar and easy to set up:

We add the following Rollup dependencies:

    "rollup": "=0.58.2",
    "rollup-plugin-babel": "=3.0.4",
    "rollup-plugin-uglify": "=3.0.0"
!function(_){_.__DEV__=!1,_.__BUNDLE_START_TIME__=Date.now()}("undefined"!=typeof global?global:"undefined"!=typeof self?self:this);
!function(r){"use strict";function t(r,t){r in u||(u[r]={factory:t,hasError:!1,isInitialized:!1,exports:void 0})}function i(r){var t=u[r];return t&&t.isInitialized?t.exports:e(r,t)}function e(t,i){if(!s&&r.ErrorUtils){s=!0;var e=void 0;try{e=o(t,i)}catch(t){r.ErrorUtils.reportFatalError(t)}return s=!1,e}return o(t,i)}function o(t,e){var o=r.nativeRequire;if(!e&&o&&(o(t),e=u[t]),!e)throw n(t);if(e.hasError)throw a(t);e.isInitialized=!0;var s=e.exports={},c=e,f=c.factory;try{var l={exports:s};return f(r,i,l,s),e.factory=void 0,e.exports=l.exports}catch(r){throw e.hasError=!0,e.isInitialized=!1,e.exports=void 0,r}}function n(r){var t='Requiring unknown module "'+r+'".';return Error(t)}function a(r){return Error('Requiring module "'+r+'", which threw an exception.')}r.require=i,r.__d=t;var u=Object.create(null),s=!1}("undefined"!=typeof global?global:"undefined"!=typeof self?self:th
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"os"
"path"
import "reflect-metadata";
import resty, {
Controller,
Get,
Request,
Response,
NextFunction,
Post,
Body,
Put,