Skip to content

Instantly share code, notes, and snippets.

@rgarciaj
rgarciaj / nginx-tuning.md
Created October 3, 2019 17:06 — 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.

@rgarciaj
rgarciaj / delete_all_tweets.py
Created June 26, 2018 21:26 — forked from davej/delete_all_tweets.py
This script will delete all of the tweets in a specified account.
# -*- coding: utf-8 -*-
"""
This script will delete all of the tweets in the specified account.
You may need to hit the "more" button on the bottom of your twitter profile
page every now and then as the script runs, this is due to a bug in twitter.
You will need to get a consumer key and consumer secret token to use this
script, you can do so by registering a twitter application at https://dev.twitter.com/apps
@requirements: Python 2.5+, Tweepy (http://pypi.python.org/pypi/tweepy/1.7.1)
@rgarciaj
rgarciaj / validar_rut.php
Last active January 29, 2018 20:28 — forked from punchi/validar_rut.php
Validar Rut en php
<?php
/**
* Comprueba si el rut ingresado es valido
* @param string $rut RUT
* @return boolean
*/
public function valida_rut($rut)
{
if (!preg_match("/^[0-9.]+[-]?+[0-9kK]{1}/", $rut)) {
@rgarciaj
rgarciaj / gist:f4f7368b463b23985843
Last active September 2, 2015 20:04 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

/**
* This function will connect wp_mail to your authenticated
* SMTP server. This improves reliability of wp_mail, and
* avoids many potential problems.
*
* Author: Chad Butler
* Author URI: http://butlerblog.com
*
* For more information and instructions, see:
* http://b.utler.co/Y3
@rgarciaj
rgarciaj / Comando
Created April 28, 2015 15:51
Crear certificado HTTPS para Apache
sudo openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/DOMINIO.pem -keyout /etc/apache2/ssl/DOMINIO.key
@rgarciaj
rgarciaj / Comandos
Last active August 29, 2015 14:11
RoR Tablas con regiones y comunas
=== Crear pais
rails g model Country name:string
=== Crear Region
rails g model Region short_name:string name:string code:string country:belongs_to
=== Crear Comunas
rails g model County name:string region:belongs_to
// para cambiar los placeholders de backbone por los de mustach
_.templateSettings = {
interpolate: /\{\{\=(.+?)\}\}/g,
evaluate: /\{\{(.+?)\}\}/g
};

Rails Boilerplate

  • Iniciar MySQL

      mysql.server start
    
  • Iniciar PostgreSQL

pg start

# Crear gemset global
rvm gemset create global
rvm use @global
# Instalar Passenger en el gemset global
gem install bundler passenger capistrano hirb wirble