Skip to content

Instantly share code, notes, and snippets.

View JonatanSalas's full-sized avatar
🤓
Open sourcing

Jonatan E. Salas JonatanSalas

🤓
Open sourcing
View GitHub Profile
@JonatanSalas
JonatanSalas / test.jsx
Last active June 12, 2020 22:58
Integrar mercadopago-checkout en class component
import React, { Component } from 'react';
import {
Text,
Alert,
View,
TextInput,
Dimensions,
TouchableOpacity,
ActivityIndicator,
Modal,
@JonatanSalas
JonatanSalas / nginx-tuning.md
Created September 18, 2018 14:00 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@JonatanSalas
JonatanSalas / Install-nginx-with-http2-support.md
Created September 18, 2018 03:24 — forked from hollodotme/Install-nginx-with-http2-support.md
Install nginx with http2 support on ubuntu 14.04 LTS (Trusty)

How to install nginx (>= 1.9.5) with http2 support on Ubuntu 14.04 LTS (Trusty)

IMPORTANT: Backup your nginx site configs (usually under /etc/nginx/sites-available)!

Remove old nginx

Remove old nginx incl. nginx-common:

apt-get autoremove --purge nginx nginx-common
import { AsyncStorage } from 'react-native';
class Storage {
static async setItem(key, value, cb) {
try {
await AsyncStorage.setItem(`${key}`, JSON.strigify(value), cb);
return true;
} catch (err) {
return false;
import React from "react";
import { SimpleCache } from "simple-cache-provider";
const withCache = Component => props => (
<SimpleCache.Consumer>
{cache => <Component cache={cache} {...props} />}
</SimpleCache.Consumer>
);
export default withCache;
import React, { Timeout } from "react";
export default class Placeholder extends React.Component {
render() {
return (
<Timeout ms={this.props.delayMs}>
{didTimeout => didTimeout ? this.props.fallback : this.props.children}
</Timeout>
);
}
import React from 'react';
import withCache from './withCache';
import newsFecher from './newsFetcher';
import Placeholder from './Placeholder';
@withCache
export default class News extends React.Component {
static getDerivedStateFromProps = (nextProps, nextState) => ({
news: newsFetcher(nextProps.cache)
import React from 'react';
import withCache from './withCache';
import newsFecher from './newsFetcher';
import Placeholder from './Placeholder';
@withCache
export default class News extends React.Component {
render() {
const news = newsFetcher(this.props.cache);
import { createResource as createFetcher } from 'simple-cache-provider';
const newsFetcher = createFetcher(async () => {
const res = await fetch(`https://jsonplaceholder.typicode.com/posts`);
return await res.json();
});
export default newsFetcher;
@JonatanSalas
JonatanSalas / News.js
Last active September 29, 2018 14:20
React Suspense
import React from 'react';
import withCache from './withCache';
import newsFecher from './newsFetcher';
import Placeholder from './Placeholder';
@withCache
export default class News extends React.Component {
render() {
const news = newsFetcher(this.props.cache);