Skip to content

Instantly share code, notes, and snippets.

View Yogendra0Sharma's full-sized avatar
🎯
Focusing

Yogendra Sharma Yogendra0Sharma

🎯
Focusing
View GitHub Profile
@Yogendra0Sharma
Yogendra0Sharma / nginx.default.conf
Created May 26, 2017 12:31 — forked from santoshachari/nginx.default.conf
PHP5.6 and NGINX: Install PHP56-FPM, Nginx & MySQL on EC2 with Amazon Linux AMI
# Install linux update, followed by GCC and Make
sudo yum -y update
sudo yum install -y gcc make
# Install Nginx and php56-FPM
sudo yum install -y nginx php56-fpm
# Install php56 extensions
sudo yum install -y php56-devel php-mysql php56-pdo php56-pear php56-mbstring php56-cli php56-odbc php56-imap php56-gd php56-xml php56-soap

Inspired and edited from this Digital Ocean tutorial.

Follow the steps on this gist to setup a LEMP stack with PHP 7.0.

The steps assume Nginx has been configured correctly.

Setup the root directories

For the domains example.com and test.com, create the folders.

@Yogendra0Sharma
Yogendra0Sharma / Laravel on LEMP Debug.md
Created May 26, 2017 12:31 — forked from santoshachari/Laravel on LEMP Debug.md
Debugging Laravel applications on LEMP

Logging is done in two places:

  1. storage/logs/laravel.log
  2. /var/log/nginx/error.log

Clear logs with:

> laravel.log
sudo bash -c '>error.log' #for nginx
@Yogendra0Sharma
Yogendra0Sharma / Laravel PHP7 LEMP AWS.md
Created May 26, 2017 12:31 — forked from gexchai/Laravel PHP7 LEMP AWS.md
Laravel 5.x on Ubuntu 16.x, PHP 7.x, Nginx 1.9.x

#Steps to install latest Laravel, LEMP on AWS Ubuntu 16.4 version. This tutorial is the improvised verision of this tutorial on Digitalocean based on my experience.

Install PHP 7 on Ubuntu

Run the following commands in sequence.

sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install zip unzip
@Yogendra0Sharma
Yogendra0Sharma / get.py
Created May 26, 2017 08:23 — forked from arisetyo/get.py
Using Python ElasticSearch Client
from elasticsearch import Elasticsearch
es = Elasticsearch()
res = es.get(index="belajar", doc_type='pesan', id=1)
print(res['_source'])
@Yogendra0Sharma
Yogendra0Sharma / gist:97f3c9e991d463ca5a1ac8603c6e013e
Created May 25, 2017 12:46 — forked from Inkimar/gist:5d10083c12052c17afbf56553ec43b96
building a publishing a relese with travis-ci
Github and Travis
#prereq for travis installation:
1. install travis-cli
1.1 ruby --version
-> gives 2.3
(1.2 sudo apt-get install pkg-config)
1.2 sudo apt-get install build-essential
sudo apt-get install libffi-dev
#install travis
@Yogendra0Sharma
Yogendra0Sharma / middleware.py
Created February 23, 2017 11:49 — forked from naiquevin/middleware.py
Examples for i18n using Django middleware blog post
class ChatLocaleMiddleware(object):
def process_request(self, request):
if request.path in ['/jsi18n/']:
return None
match = SHOPPER_CHAT_PATH.match(request.path)
if match is not None:
appid = match.groups()[0]
try:
store = Store.objects.get(appid=appid)
@Yogendra0Sharma
Yogendra0Sharma / via_button.html
Created February 23, 2017 11:48 — forked from VolgaStack/via_button.html
Django i18n changing site language
<form action="{% url 'set_language' %}" method="post">
{% csrf_token %}
<input name="next" type="hidden" value="{{ request.get_full_path|slice:'3:' }}" />
<input name="language" type="hidden" value="es" />
<input type="submit" value="ES" />
</form>

Django Idioms

General Tips

  • put methods that apply to a single instance of a Model on the model class itself
  • put methods meant to query against a Models entire table that models corresponding managers.py file.
  • if a models.py file gets too long to manage then create a models directory and place an __init__ file in it.
  • try to avoid using signals, but if you must then put them in a signals.py file