Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Getting 1% better than yesterday

Eugene Oliveros yujinyuz

:octocat:
Getting 1% better than yesterday
View GitHub Profile
View using-multiple-github-accounts-with-ssh-keys.md

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@yujinyuz
yujinyuz / api_backends.conf
Created Aug 10, 2021 — forked from nginx-gists/api_backends.conf
Deploying NGINX Plus as an API Gateway, Part 1
View api_backends.conf
upstream warehouse_inventory {
zone inventory_service 64k;
server 10.0.0.1:80;
server 10.0.0.2:80;
server 10.0.0.3:80;
}
upstream warehouse_pricing {
zone pricing_service 64k;
server 10.0.0.7:80;
@yujinyuz
yujinyuz / update_tenants_contenttype_id.py
Created Dec 20, 2020
Update tenant's ContentType.id
View update_tenants_contenttype_id.py
from django.apps import apps
from django.contrib.contenttypes.models import ContentType
from django.core.management.base import BaseCommand
from django.db import connection
from django.db.models import Case, F, Value, When
from django_tenants.utils import schema_context
from tenant.models import Tenant
@yujinyuz
yujinyuz / productiondebug.py
Created Nov 5, 2020
Allow debugging in production for superusers
View productiondebug.py
# core/middleware.py
import sys
from django.views.debug import technical_500_response
class UserBasedExceptionMiddleware:
def process_exception(self, request, exception):
if request.user.is_superuser:
return technical_500_response(request, *sys.exc_info())
@yujinyuz
yujinyuz / backup.crontab
Created Oct 25, 2020 — forked from rampion/backup.crontab
better vim backup strategy
View backup.crontab
# clean up any backups not used in the past 7 days out of the ~/.backup directory
@daily find ~/.backup -type f -name '*;*' -not \( -atime 0 -or -atime 1 -or -atime 2 -or -atime 3 -or -atime 4 -or -atime 5 -or -atime 6 \) -delete
@yujinyuz
yujinyuz / Ctags.md
Created Feb 16, 2020 — forked from przbadu/Ctags.md
Ctags for ruby on rails and node applications
View Ctags.md

Install ctags

http://ctags.sourceforge.net follow this url for installation and documentation.

Ctags with Ruby/Rails

We can ctags lots of programming languages. Here is how to do it for ruby/rails. I really like how RubyMine jumps to the source code (either withing project score or to the gem source). This is really useful for reading source code for those classes, methods, modules etc. But Now that I use vim as My IDE/Editor I really like that functionality to happen in my vim editor. And I found ctags as the solution.

@yujinyuz
yujinyuz / gist:55a8192e0435dcb864f87d9baa26bf61
Created Jul 4, 2018 — forked from Atem18/gist:4696071
Tutorial to seting up a django website in production.
View gist:55a8192e0435dcb864f87d9baa26bf61

Set up Django, Nginx and Gunicorn in a Virtualenv controled by Supervisor

Steps with explanations to set up a server using:

  • Virtualenv
  • Virtualenvwrapper
  • Django
  • Gunicorn
@yujinyuz
yujinyuz / README.md
Created Mar 19, 2018 — forked from genomics-geek/README.md
Setup ReactJS, Redux, Webpack with React Hot Reloading on an existing Django Project
View README.md

Setting up ReactJS/Redux using Webpack for an existing Django project

This guide will help set up your django project to use ReactJS

1. Install Python dependencies

Add pip requirements to our django project:

  • django-webpack-loader==0.4.1 ( Connects Django project with Webpack)
@yujinyuz
yujinyuz / django-url-patterns.md
Created Nov 19, 2017 — forked from killown/django-url-patterns.md
List of Useful URL Patterns (Django)
View django-url-patterns.md

Primary Key AutoField

Regex: (?P\d+)

url(r'^questions/(?P\d+)/$', views.question_details, name='question_details'),

Match

|URL |Captures |

@yujinyuz
yujinyuz / beautiful_idiomatic_python.md
Created Oct 16, 2017 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!
View beautiful_idiomatic_python.md

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]: