Skip to content

Instantly share code, notes, and snippets.

View gnzandrs's full-sized avatar

Gonzalo Vergara gnzandrs

View GitHub Profile
@gnzandrs
gnzandrs / nginx.conf.example
Last active June 6, 2017 21:53
This is a basic configuration to work with php5.6 with nginx on Linux
server {
listen 80;
error_log /var/log/nginx/php5.log error;
root /var/www/html;
index index.php index.html index.htm;
server_name example.local;
# You would need this line if you want to allow CORS on your server
@gnzandrs
gnzandrs / AWSS3BuckePolicy
Last active February 8, 2018 20:09
This is a Bucket Policity to Amazon Web Services S3 bucket that allows you read all the files under base directories. For example, you can use this for serve css and js bundles from s3 without use a ACL at the moment of the object upload.
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"ExampleFolderACL",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::my-bucket-name/*/*"]
}
@gnzandrs
gnzandrs / medium-react-key-example.jsx
Created November 27, 2018 14:55
react key atribute example for medium
// forma incorrecta
render() {
return (
<div>
{(
this.state.usuarios.map((id, index) => {
return <Usuario
key = {index}
id = {id}
/>
@gnzandrs
gnzandrs / script.sh
Created January 2, 2019 19:03 — forked from tonylukasavage/script.sh
Move all uncommitted changes to a new branch and revert the existing branch to HEAD. "master" has uncommitted changes. You decided you'd rather make those changes in "dev_branch". Here's how to move those uncommitted changes to "dev_branch" and then revert "master" to its last commit.
# get into the master branch
git checkout master
# create a new branch for the changes and check it out
git checkout -b dev_branch
# stash the changes until we revert master
git stash
# go back to master
@gnzandrs
gnzandrs / nginx-tuning.md
Created January 22, 2019 20:24 — 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.

@gnzandrs
gnzandrs / mapbox-render-node-react.jsx
Created February 10, 2019 02:59
mapbox rendering with react and node client-side for medium
import React from 'react'
let mapboxgl;
if (__CLIENT__) {
mapboxgl = require('mapbox-gl')
mapboxgl.accessToken = 'yourkeyhere';
}
class Map extends React.Component {
constructor() {
@gnzandrs
gnzandrs / medium-serverless-basic-config.yml
Created April 1, 2019 02:46
serverless basic configuration file example for medium
service: hola-mundo
plugins:
- serverless-offline
provider:
name: aws
runtime: nodejs6.10
stage: dev
region: us-west-2
@gnzandrs
gnzandrs / medium-dotnetcore-appsettings.json
Created April 18, 2019 15:18
dotnet core development connectionstring example
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
@gnzandrs
gnzandrs / medium-dotnet-context.cs
Created April 18, 2019 15:38
data base context class for dotnet core
using Microsoft.EntityFrameworkCore;
namespace DotNetApi.Models
{
public class dbContext : DbContext
{
public dbContext(DbContextOptions<dbContext> options)
: base(options)
{
}
@gnzandrs
gnzandrs / medium-startup.cs
Created April 18, 2019 15:50
Startup file example for a defaultconnection added in services.
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using DotNetApi.Models;
namespace DotNetApi
{