Skip to content

Instantly share code, notes, and snippets.

View rbtsolis's full-sized avatar
👨‍💻

Roberth Solís rbtsolis

👨‍💻
View GitHub Profile
@ismailmechbal
ismailmechbal / sketch-never-ending.md
Last active January 28, 2022 04:23
Modify Sketch to never ending trial

###Sketch trial non stop

Open hosts files:

$ open /private/etc/hosts

Edit the file adding:

127.0.0.1 backend.bohemiancoding.com

127.0.0.1 bohemiancoding.sketch.analytics.s3-website-us-east-1.amazonaws.com

@alexdzul
alexdzul / PaginatingDjango
Last active June 17, 2018 22:23
Paginación inteligente con Django Template Engine
<!--
autor: Alex Dzul @alexjs88
Supongamos que tenemos miles de objetos a paginar. Django por sí solo no cuenta con una función que nos
permita definir cuántas páginas queremos mostrar y en tu template te podría aparecer miles de páginas:
< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 N1.. N2.. etc ... >
Si en nuestro sitio solo queremos mostrar un fragmento de páginas, entonces con este SNIP podemos definir
el intervalo de páginas hacia la izquierda y hacia la derecha que necesitamos.
@cansadadeserfeliz
cansadadeserfeliz / pipeline.py
Last active December 10, 2018 21:03
Django: python-social-auth configuration and pipeline to get users email, full name and save avatar for Facebook, Twitter, LinkedIn and Google http://blog.vero4ka.info/blog/2015/03/02/django-python-social-auth-configuration-and-pipeline-to-get-users-information/
def update_user_social_data(strategy, *args, **kwargs):
"""Set the name and avatar for a user only if is new.
"""
print 'update_user_social_data ::', strategy
if not kwargs['is_new']:
return
full_name = ''
backend = kwargs['backend']
@yprez
yprez / fields.py
Last active February 19, 2023 12:08
Django rest framework - Base64 image field
import base64
from django.core.files.base import ContentFile
from rest_framework import serializers
class Base64ImageField(serializers.ImageField):
def from_native(self, data):
if isinstance(data, basestring) and data.startswith('data:image'):
# base64 encoded image - decode
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@beaufour
beaufour / language.py
Created November 30, 2012 16:00
Django Middleware to choose language based on subdomain
import logging
from django.utils import translation
class SubdomainLanguageMiddleware(object):
"""
Set the language for the site based on the subdomain the request
is being served on. For example, serving on 'fr.domain.com' would
make the language French (fr).