Skip to content

Instantly share code, notes, and snippets.

View ronbeltran's full-sized avatar

Ronnie Beltran ronbeltran

View GitHub Profile
@ronbeltran
ronbeltran / DiagnoseRedisErrors-ClientSide.md
Created January 21, 2018 06:26 — forked from JonCole/DiagnoseRedisErrors-ClientSide.md
Diagnosing Redis errors caused by issues on the client side

Diagnosing Redis errors on the client side

Customers periodically ask "Why am I getting errors when talking to Redis". The answer is complicated - it could be a client or server side problem. In this article, I am going to talk about client side issues. For server side issues, see here

Clients can see connectivity issues or timeouts for several reason, here are some of the common ones I see:


Memory pressure

{
"device_model": "iPad",
"is_bot": false,
"os_version": "5.1",
"browser_version": "5.1",
"device_brand": "Apple",
"device_type": "Tablet",
"os": "iOS",
"browser": "Mobile Safari UI/WKWebView"
}
import json
import requests
token = "your-api-token"
headers = {
"Content-Type": "application/json",
"Authorization": "Token {}".format(token)
}
payload = {
"useragent": "Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176"
@ronbeltran
ronbeltran / .ebextensions\deploy.config
Created December 12, 2017 06:49 — forked from pdib/.ebextensions\deploy.config
Installing node and npm on a Django AWS ElasticBeanstalk
# This specifies the deployment process on AWS ElasticBeanstalk for a Django app using npm and Postgres.
#
# The target environment should have access to a Postgres Database through environment variables.
# The environment can be setup using `eb create --database.engine=postgres`
# The necessary environment variables to access the database will be automatically defined on the
# instances of that environment.
#
# In addition, the target environment should define environment variables (django secret key ...).
# They can be manually defined using the AWS ElasticBeanstalk interface on the web.
# They can also be specified when creating the environment from command line, for example:
@ronbeltran
ronbeltran / gunicorn_start.bash
Created December 1, 2017 13:25 — forked from postrational/gunicorn_start.bash
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name
@ronbeltran
ronbeltran / Django_ReactJS_Webpack_project_setup.md
Created November 27, 2017 07:03 — forked from Belgabor/Django_ReactJS_Webpack_project_setup.md
Set up a Django + ReactJS project with Webpack manager

Guide on how to create and set up your Django project with webpack, npm and ReactJS :)

Hopefully this will answer "How do I setup or start a Django project?" I was trying to set up my own website, and there was a lot to read, learn and digest! Therefore, I put this together which is a collection of all the guides/blog posts/articles that I found the most useful. At the end of this, you will have your barebones Django app configured and ready to start building :)

NOTE: This guide was built using Django 1.9.5, NodeJS 4+ with NPM 3+

1. Setting up your dev environment

@ronbeltran
ronbeltran / ratelimit.nginxconf
Created July 27, 2017 09:20 — forked from ipmb/ratelimit.nginxconf
Nginx reverse proxy with rate limiting
upstream myapp {
server 127.0.0.1:8081;
}
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
server {
listen 443 ssl spdy;
server_name _;
@ronbeltran
ronbeltran / gist:7500ff0041300c7be405c85f048b5bed
Created July 24, 2017 04:44 — forked from GrahamDumpleton/gist:b380652b768e81a7f60c
Setting environment variables for Apache/mod_wsgi hosted Python application.

Django documentation says to use:

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonPath /path/to/mysite.com

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted
@ronbeltran
ronbeltran / gist:36e376a36e9c2db0665f50fc7f8635e6
Created July 19, 2017 11:18 — forked from pnommensen/gist:707b5519766ba45366dd
Ghost CMS with NGINX for Maximum Performance

Full blog post can be found here: http://pnommensen.com/2014/09/07/high-performance-ghost-configuration-with-nginx/

Ghost is an open source platform for blogging founded by John O'Nolan and Hannah Wolfe. It's a node.js application and therefore works great in conjunction with nginx. This guide will will help you create a high performance nginx virtual host configuration for Ghost.

"Don't use #nodejs for static content" - @trevnorris. If #nginx isn't sitting in front of your node server, you're probably doing it wrong.

— Bryan Hughes (@nebrius) August 30, 2014
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

The node.js application runs on a port on your server

@ronbeltran
ronbeltran / settings.py
Created June 21, 2017 08:58 — forked from palewire/settings.py
My current default Django LOGGING configuration
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
},
'null': {
'level':'DEBUG',