Skip to content

Instantly share code, notes, and snippets.

View yujinyuz's full-sized avatar
:octocat:
Getting 1% better than yesterday

Eugene Oliveros yujinyuz

:octocat:
Getting 1% better than yesterday
View GitHub Profile

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 August 10, 2021 07:31 — forked from nginx-gists/api_backends.conf
Deploying NGINX Plus as an API Gateway, Part 1
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 December 20, 2020 13:46
Update tenant's ContentType.id
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 November 5, 2020 04:21
Allow debugging in production for superusers
# 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 October 25, 2020 23:49 — forked from rampion/backup.crontab
better vim backup strategy
# 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 February 16, 2020 14:00 — forked from przbadu/Ctags.md
Ctags for ruby on rails and node applications

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 July 4, 2018 15:10 — forked from Atem18/gist:4696071
Tutorial to seting up a django website in production.

******************************************************************** 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 March 19, 2018 14:11 — forked from genomics-geek/README.md
Setup ReactJS, Redux, Webpack with React Hot Reloading on an existing Django Project

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 November 19, 2017 13:59 — forked from killown/django-url-patterns.md
List of Useful URL Patterns (Django)

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 October 16, 2017 07:26 — 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!

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]: