This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk MACOSX_DEPLOYMENT_TARGET=10.14 pyenv install 3.7.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoload -Uz compinit | |
compinit | |
ZSH_THEME="powerlevel9k/powerlevel9k" | |
# Load Nerd Fonts with Powerlevel9k theme for Zsh | |
POWERLEVEL9K_MODE='nerdfont-complete' | |
source ~/powerlevel9k/powerlevel9k.zsh-theme | |
# Customise the Powerlevel9k prompts | |
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh dir vcs newline status) | |
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=() | |
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Clonar un repositorio de github | |
$ git clone <nombre del repo> | |
Listas las ramas y ver la activa | |
$ git branch | |
Crear una rama a partir de la rama actual | |
$ git checkout -b NombreDeLaRama | |
Guardar el Trabajo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In local settings. | |
"python.autoComplete.extraPaths": ["backend/"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from djmoney.contrib.django_rest_framework import MoneyField | |
from moneyed import Money, Decimal | |
class MyMoneyField(MoneyField): | |
def to_representation(self, obj): | |
return { | |
'amount': "%f" % (obj.amount), | |
'currency': "%s" % (obj.currency), | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Handling Errors using async/await | |
* Has to be used inside an async function | |
*/ | |
try { | |
const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
// Success 🎉 | |
console.log(response); | |
} catch (error) { | |
// Error 😨 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
full_name = serializers.SerializerMethodField('get_user_full_name') | |
def get_user_full_name(self, obj): | |
request = self.context['request'] | |
user = request.user | |
name = user.first_name + " " + user.last_name | |
return name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If modifying these scopes, delete the file token.pickle. | |
SCOPES = [ | |
'openid', | |
'https://www.googleapis.com/auth/userinfo.email', | |
] | |
def get_user_info(credentials): | |
"""Send a request to the UserInfo API to retrieve the user's information. | |
user_email = get_user_info(credentials)['email'] | |
Args: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I don't think Django queryset has a mechanism to order by a list of field value. | |
Option 1: | |
Order in Python. Keep it mind it will return a list, not a queryset anymore (inspired from this answer) and that you end up using magic strings (what if the user uses Entrées instead of Starters?): | |
sections = Section.objects.all() | |
order = ['Starters', 'Salads', 'Desserts'] | |
order = {key: i for i, key in enumerate(order)} | |
ordered_sections = sorted(sections, key=lambda section: order.get(section.name, 0)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.admin.widgets import AdminDateWidget | |
class YourForm(forms.ModelForm): | |
from_date = forms.DateField(widget=AdminDateWidget()) | |
add | |
{{ form.media }} | |
from django.contrib.admin.widgets import AdminDateWidget |