Skip to content

Instantly share code, notes, and snippets.

// Sendbird widget
#sb_widget
.widget
background-color: $primary !important
&:hover
background-color: darken($primary, 10%) !important
.channel-board .board-top
background-color: $primary !important
@adrienlachaize
adrienlachaize / sync_perms
Last active September 29, 2015 14:28
Refresh apps permissions
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.apps import apps
from django.db.models import get_models
from django.core.management.base import BaseCommand
from django.contrib.auth.management import create_permissions
class Command(BaseCommand):
@adrienlachaize
adrienlachaize / gist:47dd796917cd6b7cd1b1
Created November 26, 2014 21:53
Djang slugify a string to Twitter hashtag format
import re
import unicodedata
try:
from django.utils.encoding import smart_unicode as smart_text
except ImportError:
from django.utils.encoding import smart_text
SLUG_OK = '_'
@adrienlachaize
adrienlachaize / gist:e1caa489bad8a96629c6
Created November 26, 2014 21:49
Wonderfull HTTP response to json format
import json
from django.http import HttpResponse
def json_responder(**kwargs):
"""
Return a HTTP response to json format
"""
return HttpResponse(json.dumps(kwargs), content_type="application/json")
@adrienlachaize
adrienlachaize / gist:11180962
Created April 22, 2014 14:17
Import settings apps of a Django project
"""
Paste the code at the end your main settings.
It will import all settings files of your django project.
It allow to divide settings per app.
"""
import os.path
for d in [d for d in os.listdir(os.path.dirname(__file__)) if os.path.isdir(os.path.join(os.path.dirname(__file__), d))]:
app = __import__(d)
@adrienlachaize
adrienlachaize / gist:8349832
Created January 10, 2014 10:37
Check if the given file is .txt
import mimetypes
def is_txt_file(file):
"""Test if the file is a txt file."""
mime = mimetypes.guess_type(file)
if mime[0] == 'text\plan':
return True
@adrienlachaize
adrienlachaize / gist:8349814
Created January 10, 2014 10:36
Get system os struct.
import struct
def get_os_struct():
"""Get system os struct."""
return str(struct.calcsize('P') * 8)